以下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
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/14 05:29:23
以下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
以下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题目在线等(判断大数质数)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
用JAVA里面的prime函数.