文章

116

粉丝

0

获赞

119

访问

6.4k

头像
素数判定 - 哈尔滨工业大学 题解:
P1355 哈尔滨工业大学机试
发布于2026年2月5日 17:09
阅读数 44

#include<bits/stdc++.h>
using namespace std;
bool isPrime(int x) {
    if (x <= 1) 
		return false;
    for (int i = 2; i * i <= x; ++i)
        if (x % i == 0) 
			return false;
    return true;
}
int main(){
	int n;
	while(cin >> n){
		if(isPrime(n))
			cout << "yes";
		else
			cout << "no";
	}
	return 0;
}	

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发