文章

74

粉丝

0

获赞

98

访问

8.9k

头像
素数判定 - 哈尔滨工业大学 题解:
P1355 哈尔滨工业大学机试
发布于2025年8月9日 16:16
阅读数 121

#include<bits/stdc++.h>
using namespace std;

bool isPrime(int a){
	if(a <= 1) return false;
	for(int i = 2; i <= sqrt(a); i ++){
		if(a % i == 0) return false;
	}
	return true;
}

int main(){
	int t;
	while(cin >> t){
		if(isPrime(t)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发