主站
DreamJudge
院校信息
专业题库
模拟考试
机试真题
专业课程
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
2018024342
2024年3月31日 12:33
素数判定 题解:为什么有错误啊佬们,dev c++能通过
P1102
回复 5
|
赞 0
|
浏览 198
#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
|
浏览 145
#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
|
浏览 187
#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
|
浏览 165
#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
|
赞 0
|
浏览 142
#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...
huanghu
2024年3月13日 00:06
素数判定 题解:
P1102
回复 0
|
赞 0
|
浏览 113
#include<stdio.h> #include<iostream> using namespace std; bool ss(int a){ for(int i = 2; i<=a/2; i++){ if(a%i == 0){ return false; } } return true; } //给你两个数a、b,现在的问题是要判断这两个数组成的区间内共有多少个素数 int main(){ int a,b; while...
lingdongyang
2024年3月10日 11:31
素数判定 题解:
P1102
回复 0
|
赞 0
|
浏览 162
#include<stdio.h> #include<math.h> int main() { int a, b; while (scanf("%d%d", &a, &b) != EOF) { int cnt = 0; if (a > b) { int t = b; b = a; a = t; } for (int i = a; i <= b; i++) {//从a到b之间每个数进行判定 int flag = 0; for (int j = 2; j <...
orderrr
2024年3月4日 15:17
素数判定 题解:c 多谢评论区的指正,需要提前判断a,b谁大谁小
P1102
回复 0
|
赞 0
|
浏览 123
#include <stdio.h> #include <math.h> int main() { int a, b; while (scanf("%d %d", &a, &b) != EOF) { if (b < a) { int temp = a; a = b; b = temp; } int cnt = 0; // 记录素数的个数 ...
小王桐学
2024年2月6日 16:39
素数判定 题解:C
P1102
回复 0
|
赞 0
|
浏览 182
#include <stdio.h> #include <math.h> int isPrimary(int n) { int i; for(i = 2; i <= sqrt(n); i++) if(n % i == 0) break; if(i > sqrt(n)) return 1; else return 0; } int Primary(int a,int b) { int i,count = 0; if(a > b) { i = a; a = b; b = ...
peterzhou
2023年7月30日 13:34
素数判定 题解:简洁快速
P1102
回复 0
|
赞 1
|
浏览 500
#include <bits/stdc++.h> using namespace std; int isprime(int n) { vector<int> a(n, 0); int cnt = 0; a[0] = a[1] = 1; for (int i = 2; i < n; i++) { if (!a[i]) { &...
1
2
题目
素数判定
题解数量
17
发布题解
热门题解
1
素数判定 题解:简洁快速
2
[c]易错点为:if a>b则需要交换a与b的值
3
P1102 素数判定
4
素数判定 题解:为什么有错误啊佬们,dev c++能通过
5
素数判定 题解:注意a、b两个数的大小关系
6
素数判定 题解:
7
素数筛选办法
8
素数判定 题解:c 多谢评论区的指正,需要提前判断a,b谁大谁小
9
素数判定 题解:C
10
C++