51Nod-1186-質數檢測 V2 JAVA biginteger包



輸入已經是大數  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");
		}
	}

}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章