輸入已經是大數 C++需要高精度 這裏用JAVA 簡單一點 直接操作。
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in
);
BigInteger x;
x = in.nextBigInteger();
if(x.isProbablePrime(1))
{
System.out.println("Yes");
}
else
{
System.out.println("No");
}
}
}