Accept: 238Submit: 1098
Time Limit: 2000 mSecMemory Limit : 32768 KB
Problem Description
Your task is simple.
Give you a number N, you should judge whether N is a prime number or not.
Input
There are multiple test cases. For each test case, there is an integer N(2<=N<=10^18).
Output
For each test case, you should output whether N is a prime number or not.
If N is a prime number , you should output "It is a prime number."; otherwise you should output "It is not a prime number.";
Sample Input
2
4
Sample Output
It is a prime number.
It is not a prime number.
--------------------------------------------------------------------------------------
我发现java越来越暴力了
import java.math.BigInteger; import java.util.Scanner; public class Main { static BigInteger b; public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()) { b=in.nextBigInteger(); if(b.isProbablePrime(1)) System.out.println("It is a prime number."); else System.out.println("It is not a prime number."); } } }