首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
牧濑
2026年2月11日 13:39
判断素数 题解:素数定义+枚举
P1013
回复 0
|
赞 12
|
浏览 184
#include <iostream> using namespace std; int main(){ int n; cin>>n; bool isSS=true; //根据定义,1不是素数,偶数除了2都不是素数 //即只有2,和大于2的奇数可能是素数 if((n%2==0&&n>2)||n==1) isSS=false; else{ //判断当前数是否是素数 for(int i=2;i*i<=n;i++){ if(n%i==0) ...
yauqq
2026年2月5日 17:07
判断素数 题解:
P1013
回复 0
|
赞 6
|
浏览 214
#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; cin >> n; if(isPrime(n)){ cout << ...
xsw
2026年2月2日 11:49
判断素数 题解:
P1013
回复 0
|
赞 1
|
浏览 164
#include<iostream> using namespace std; bool is_prime(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; cin >> n; if (is_prime(n)) cout << n << endl; ...
mlx
2026年1月29日 12:27
判断素数 题解:
P1013
回复 0
|
赞 4
|
浏览 186
#include<iostream> using namespace std; bool check(int n) { if(n<=1) return false; if(n==2) return true; for(int i=2;i*i<=n;i++) if(n%i==0) return false; return true; } int main() { int n; cin>>n; if(check(n)) cout<<n; else { ...
曾不会
2026年1月24日 09:39
判断素数 题解:
P1013
回复 0
|
赞 2
|
浏览 244
#include<stdio.h> #include<math.h> int fun(int x) { for(int i=2;i<=sqrt(x)+1;i++) { if(x%i==0) { return...
16696033405
2025年3月25日 18:26
判断素数 题解:
P1013
回复 0
|
赞 11
|
浏览 1.1k
#include<stdio.h> #include<string.h> #include<ctype.h> #include<math.h> #define MAX 1000 int main(){ int n; scanf("%d",&n); int i,j; for(i=2;i<n;i++){ ...
阿灿
2025年3月25日 10:59
判断素数 题解:
P1013
回复 0
|
赞 5
|
浏览 1.1k
#include<bits/stdc++.h> using namespace std; bool shu(int x){ if(x<2) return false; for(int i=2;i<=sqrt(x);i++){ if(x%i==0) return false; } return true; } int main(){ int n; cin>>n; for(int i=n;;i++){ if(shu(i)){ cout<<i<<endl; break...
cc12345
2025年3月20日 22:15
判断素数 题解:<=sqrt平方根进行%判断
P1013
回复 0
|
赞 6
|
浏览 1.1k
#include<bits/stdc++.h> using namespace std; bool isPrime(int n) { if(n<2) return false; for(int i=2;i<=sqrt(n);i++) { if(n%i==0) { return false; } } return true; } int main() { int n; cin>>n; while(isPrime(n)){ //若为true,代表n为素数,输出; cout<<...
jaygee_
2025年3月6日 09:17
判断素数 题解:
P1013
回复 0
|
赞 24
|
浏览 1.2k
#include<bits/stdc++.h> using namespace std; bool isPrime(int n) { if (n < 2) return false; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } int main() { int n; cin >>...
Txh
2025年3月2日 21:43
判断素数 题解:
P1013
回复 2
|
赞 8
|
浏览 1.2k
一直卡在80% 求解答 #include<stdio.h> int main(){ int number; int a; scanf("%d",&number); if(number>10000){ return 0; &nbs...
1
2
3
4
...
6
题目
判断素数
题解数量
54
发布题解
在线答疑
热门题解
1
【C语言】看了很多,感觉代码太麻烦,可以参考我的
2
判断素数 题解:
3
判断素数 题解:素数定义+清晰思路
4
判断素数 题解:素数定义+枚举
5
判断素数 题解:
6
判断素数 题解:
7
判断素数 题解:
8
判断素数 题解:
9
判断素数 题解:
10
判断素数 题解: