主站
DreamJudge
院校信息
专业题库
模拟考试
机试真题
专业课程
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
我能走到对岸吗
2024年4月20日 12:12
判断素数 题解:
P1013
回复 0
|
赞 1
|
浏览 63
#include<bits/stdc++.h> using namespace std; int n; bool cheak(int n) { if(n == 1) return false; for(int i = 2; i * i < n; i ++) if(n % i == 0) return false; return true; } int main() { cin >> n; if(cheak(n)) cout <&l...
20082123
2024年3月28日 16:17
判断素数 题解:
P1013
回复 0
|
赞 0
|
浏览 177
#include<bits/stdc++.h> using namespace std; bool sx(int a){ if(a<2)//边界情况 return false; for(int i=2;i<sqrt(a);i++) if(a%i==0)  ...
easymoney
2024年3月18日 11:48
判断素数 题解:
P1013
回复 0
|
赞 0
|
浏览 414
#include <stdio.h> #include <algorithm> #include <iostream> #include <math.h> using namespace std; int main(){ int n; cin >>n; if(n == 1) n++; for(int i = n; ;i++){ int flag = 0; for(int j = 2;j < sqrt(i);j++){ if(i%j == 0) { ...
FCC
2024年3月15日 10:22
判断素数 题解:判断素数/质数:指在>1的自然数中,除了1和它本身以外
P1013
回复 0
|
赞 0
|
浏览 357
#include <bits/stdc++.h> using namespace std; /* 判断素数/质数:指在大于1的自然数中,除了1和它本身以外,不再有其他因数的自然数。*/ bool isSu( 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(...
flipped
2024年3月14日 19:10
判断素数 题解:
P1013
回复 0
|
赞 0
|
浏览 350
#include <stdio.h> #include <stdbool.h> // 函数:判断一个数是否为素数 bool isp(int n) { if (n <= 1)return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { return false; } } return true; } // 函数:查找...
周小黑02477
2024年3月13日 18:04
P1013
回复 0
|
赞 0
|
浏览 234
#include<stdio.h> #include<string> #include <stdlib.h> #include<iostream> #include<string.h> #include<algorithm> #include<math.h> using namespace std; int main() { int n; cin >> n; if (n == 1) n++; for (int i = n; i <= 1000000...
Djiangxu
2024年3月13日 16:24
判断素数 题解:关于埃氏筛选预处理打表的方法求解
P1013
回复 0
|
赞 0
|
浏览 159
埃氏筛法简述:和辗转相除法比较相似。首先将2到n范围内的整数写下来,从2开始依次找到各个素数,然后将这个素数不超过n的倍数划去。反复操作后就能得到n以内的所有素数。 例子:n = 20时 从2开始,第一遍筛掉它的倍数4、6、8、10、12、14、16、18、20,这些数都不是素数,22超过了20,结束本轮筛选。 然后3也是素数,第二遍筛掉它的倍数6、9、12、15、18,这些都不是素数。 第三遍是5,依次类推就可以得到素数表。 然后拿输入的数据来对比一下就好啦! 需要注意的点: (1)1不是素数。 (2)范围有点特殊,我算了一下有一个数据可...
A001
2024年3月13日 11:22
判断素数 题解:为什么只通过60%呢 请找出错误输入 谢谢!
P1013
回复 4
|
赞 0
|
浏览 321
#include<iostream> using namespace std; int main(){ int n; cin>>n; int flag=0; if(n<=1){ cout<<2<<endl; return 0;} &nb...
小酒
2024年3月11日 15:52
判断素数 题解:
P1013
回复 0
|
赞 0
|
浏览 172
1013解题思路 #include <bits/stdc++.h> using namespace std; int sumath(int m) { int count=0; for(int i=2;i<m;i++) { if(m%i!=0) &n...
lingdongyang
2024年3月10日 10:56
判断素数 题解:
P1013
回复 0
|
赞 0
|
浏览 226
#include<stdio.h> #include<math.h> //1013 判断素数 int main() { int n = 0; while (scanf("%d", &n) != EOF) { if (n <= 1) n = 2;//排除小于1的不是素数 for (int i = n; ; i++) { int flag = 0; for (int j = 2; j <= sqrt(n); j++) { if (i % j == 0) {//没有余数,不是素数...
1
2
3
题目
判断素数
题解数量
30
发布题解
热门题解
1
【C语言】看了很多,感觉代码太麻烦,可以参考我的
2
1013素数判断(数据可能有问题)
3
纯C不复杂
4
题解:判断素数
5
stl大法
6
判断素数
7
P1013 解题思路分享
8
c-注意小于2时不合法,要考虑
9
P1013 - 判断素数(C语言)
10
判断素数 题解: