作业帮 > 英语 > 作业

以下ACM题目在线等(判断大数质数)

来源:学生作业帮 编辑:神马作文网作业帮 分类:英语作业 时间:2024/09/20 21:38:12
以下ACM题目在线等(判断大数质数)
Problem F --- Prime or composite?(12:15:40)
This is pretty simple,but your program needs to be very efficient.The numbers may be very large.There may be a lot of numbers.Your program must read a series of numbers from standard input,and then print whether each number is prime or composite.
Input
The input consists of several line with a single value n on that line.The number n is nonegative and your program should halt on any number less than two.
Output
For each line,the output should either be the string "prime" (printed on a line by itself) or the string "composite" (printed on a line by itself.
Sample Input
2
3
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6
17
1
18
0
Junk
Sample Outputprime
prime
composite
composite
prime
以下ACM题目在线等(判断大数质数)
用JAVA里面的prime函数.