首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
阿灿
2025年3月25日 11:51
素数判定 题解:
P1102
回复 0
|
赞 2
|
浏览 222
#include<bits/stdc++.h> using namespace std; int shu(int x){ for(int i=2;i<=sqrt(x);i++){ if(x%i==0)return false; } return true; } int main(){ int a,b; int min1; int max1; while(cin>>a>>b){ int ans=0; min1 = min(a,b); max1 = max(a,b); for(...
blackbook537
2025年3月16日 20:37
素数判定 题解:
P1102
回复 0
|
赞 1
|
浏览 358
#include<stdio.h> #include<stdlib.h> int su(int num){ if(num < 2){ return 0; } for(int j = 2;j < num;j++){ if(num%j == 0){ ...
西电机试专家
2025年2月12日 10:56
素数判定 题解:素数定义+整体思路
P1102
回复 0
|
赞 11
|
浏览 507
#include <bits/stdc++.h> using namespace std; //素数是指那些大于1,并且只能被1和它自己整除的数 //思路: 判断一个数是不是素数,即用它除以小于其根号的数[2-sqrt(i)],若能整除 则说明非素数 int main(){ int a,b; while(cin>>a>>b) { int first=min(a,b); &nb...
可可爱爱草莓派
2024年9月1日 20:12
素数判定 题解:
P1102
回复 0
|
赞 1
|
浏览 1.7k
#include<bits/stdc++.h> using namespace std; const int maxn = 1000000 + 5; int prime[maxn]; void getPrime(){ memset(prime,0,sizeof prime); for(int i = 2;i < maxn;i++){ if(!prime[i]) prime[++prime[0]] = i;  ...
Candour
2024年5月10日 23:48
素数判定 (试除法 O(n*sqrt(n))题解:
P1102
回复 0
|
赞 2
|
浏览 1.6k
1000的数据量可以过 #include <bits/stdc++.h> using namespace std; int a, b; bool cheak(int x) { for(int i = 2; i <= x / i; i ++) if(x % i == 0) return false; return true; } int main() { while(cin >> a >> b) { int ans = 0; for(int i = mi...
2018024342
2024年3月31日 12:33
素数判定 题解:为什么有错误啊佬们,dev c++能通过
P1102
回复 5
|
赞 3
|
浏览 856
#include<bits/stdc++.h> using namespace std; int main(){ int a,b; while(scanf("%d %d",&a,&b)!=EOF){ int sum=0; for(int i=a;i<=b;i++){ &n...
easymoney
2024年3月19日 09:42
素数判定 题解:
P1102
回复 0
|
赞 0
|
浏览 943
#include <stdio.h> #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int maxn = 1000000 + 5; int prime[maxn]; void getprime() { memset(prime, 0, sizeof(prime)); for (int i = 2; i <= maxn; i++) { ...
光明守护神
2024年3月18日 10:56
C++
P1102
回复 0
|
赞 0
|
浏览 1.0k
#include<cmath> #include<iostream> using namespace std; bool sushu(int n) { if (n < 2) { return false; } else { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } } return true; } int main() { int a, b; while ...
Cookie‘s AE86
2024年3月17日 09:10
素数判定 题解:注意a、b两个数的大小关系
P1102
回复 0
|
赞 0
|
浏览 1.3k
#include<bits/stdc++.h> using namespace std; bool primenumberjudge(int n); int main(){ int n, m; int cnt; while(cin >> n >> m){ cnt = 0; if(n > m){ int tmp = n; n = m; m = tmp; } ...
FIVEszc
2024年3月15日 16:21
素数判定 题解:简洁易懂
P1102
回复 0
|
赞 1
|
浏览 857
#include <bits/stdc++.h> using namespace std; int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF){ int cnt=0; if(a>b){int t=a;a=b;b=t;} for(;a<=b;a++) { int tag=0; for(int i=2;i<a;i++) { if(a%i==0){tag=1...
1
2
3
题目
素数判定
题解数量
22
发布题解
在线答疑
热门题解
1
素数判定 题解:素数定义+整体思路
2
素数判定 题解:为什么有错误啊佬们,dev c++能通过
3
素数判定 题解:简洁快速
4
素数判定 (试除法 O(n*sqrt(n))题解:
5
素数判定 题解:
6
素数判定 题解:
7
[c]易错点为:if a>b则需要交换a与b的值
8
素数判定 题解:
9
素数判定 题解:
10
素数判定 题解:简洁易懂