#P1619. 解一元二次方程的烦恼

    ID: 862 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>模拟字符串数论数学洛谷原创

解一元二次方程的烦恼

题目背景

JosephZheng在写数学作业的预习。他往往使用Casio来帮忙解一元二次方程。但是Casio有一个问题,就是当Δ=b²-4ac为一个大素数或大合数时,其开平方的结果会以小数显示,而不是老师要求的二次根式形式。JosephZheng很是苦恼,一遇到这种情况就要手动解方程。一天他再也忍不住了,于是打开了电脑,编了一个prime程序……于是悲剧的OI们就要跟着疯狂的JosephZheng一起编这个程序,呵呵……

题目描述

废话少说,给你一个大数N(不一定在int64范围内),让你进行素性判断,然后分解质因数。当然,初中数学题不可能有大于int64的数让你判断素性,因此超过范围的数可以忽略不计。为了让程序更加贴心,JosephZheng多了一些要求,会在输入输出中给出具体情况。

输入格式

一个大数N(N为非负整数),其中这个数的各个位数之间可以插入各种符号,例如1234可以为1 - 2alsdkjf3!@¥%!@@@##¥……!¥#-4等。你需要在这一长串乱码中找出这个要判断的数。输入数据可能有多组,如果读到一行没有数字的字串即结束。字符串长度可能大于255。

输出格式

在读入数据之前先输出“Enter the number=”,不要换行。

读入数据完毕后writeln。

然后输出“Prime? ”,问号后有一个空格,但不要换行。

如果是质数则输出“Yes!”否则输出“No!”。此时换行。

若果是质数就halt,若是小于2的数则在输出“No!”后也halt。若是合数则分解质因数。如果该数大于四千万则输出“The number is too large!”,然后halt。否则分解质因数。输出结果的方式在输出样例中会详细给出。每组数据之间空一行。

4
eed
Enter the number=
Prime? No!
4=2^2

Enter the number=
2
end
Enter the number=
Prime? Yes!

Enter the number=
-1
adfs
Enter the number=
Prime? No!

Enter the number=
1234###24#@13#@¥!1
hehe
Enter the number=
Prime? No!
The number is too large!

Enter the number=
1.5
1
1234324123512343123
@~@~@~@
Enter the number=
Prime? No!
15=3^1*5^1

Enter the number=
Prime? No!

Enter the number=
Prime? No!
The number is too large!

Enter the number=
12
halt@@
Enter the number=
Prime? No!
12=2^2*3^1
Enter the number=

提示

编这道题的JosephZheng有些无聊,但是很考验基本功哦!仔细审题!

水题一道。。。