文章

33

粉丝

42

获赞

3

访问

7.7k

头像
素数判定 - 哈尔滨工业大学 题解:
P1355 哈尔滨工业大学机试
发布于2024年3月18日 12:10
阅读数 135

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while(cin >> n){
		int flag = 0;
	if(n == 1){
		cout << "no"<<endl;
		flag = 1;
	}
	for(int i = 2;i <= sqrt(n);i++){
		if(n%i == 0){
			cout << "no"<<endl;
			flag = 1;
		    break;
		}
	}
	if(flag == 0)
	  cout <<"yes"<<endl;
}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发