1186 质数检测 V2 (大数)

1186 质数检测 V2 

基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题

 收藏

 关注

给出1个正整数N,检测N是否为质数。如果是,输出"Yes",否则输出"No"。

Input

输入一个数N(2 <= N <= 10^30)

Output

如果N为质数,输出"Yes",否则输出"No"。

Input示例

17

Output示例

Yes

突然好喜欢Java。。。

代码:

import java.util.*;
import java.math.*;


public class zhishujiance {
	public static void main(String[] args){
		Scanner cin=new Scanner(System.in);
		BigInteger x;
		x=cin.nextBigInteger();
		if(x.isProbablePrime(1))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

猜你喜欢

转载自blog.csdn.net/sunny_hun/article/details/81407861