首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
无名吟
2026年3月15日 16:49
是(四)素数 C语言题解:埃拉托斯特尼筛法
P1740
回复 0
|
赞 5
|
浏览 110
埃拉托斯特尼筛法 #include<stdio.h> #define N 10000000 int primes[N]; int st[N],s=0; void isPrime(int n){ st[1]=0; for(int i=2; i<n; i++){ if(!st[i]){ primes[s]=i; s++; } for(int j=0; i*primes[j]<n; j++){ st[i*primes[j]]=1; if(i%primes[j]==0) break;...
上岸啊641
2026年3月14日 00:24
是(四)素数 题解:
P1740
回复 0
|
赞 1
|
浏览 76
#include <bits/stdc++.h> using namespace std; const int maxn=10000000+1; int prime[maxn]; void getprime(){ memset(prime,0,sizeof(prime)); for(int i=2;i<maxn;i++) { if(!prime[i]) prime[+...
一字清若杰
2026年2月10日 00:42
是(四)素数 题解:埃氏筛 + string
P1740
回复 0
|
赞 3
|
浏览 180
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll N = 1e7; //埃氏筛找素数 ll sum_prime(ll y) { ll count = 0; vector<ll> isprime(y + 1, 1); isprime[1] = 0; ll y1...
yauqq
2026年2月5日 20:30
是(四)素数 题解:
P1740
回复 0
|
赞 4
|
浏览 195
#include<bits/stdc++.h> using namespace std; const int MAX = 1e7; // 埃氏筛预处理素数 bool isPrime[MAX]; void sieve() { // 初始化:假设都是素数 for(int i = 0; i < MAX; i++) isPrime[i] = true; for(int i = 2; i * i < MAX; i++) { if(isPrime[i]) { for(in...
RingoCrystal
2025年2月19日 15:42
是(四)素数 题解:素数筛时限不过解决办法
P1740
回复 0
|
赞 8
|
浏览 1.6k
#include <bits/stdc++.h> using namespace std; /* bool contians4(int x){ while(x!=0){ if(x%10==4)return true; x/=10; } return false; } */ int main(){ /* int a[10000001]={0}; for(int i=2;i*i<=10000000;i++){ int j=2; ...
Fairy渚薰
2020年10月16日 22:21
素数筛,然后再判断是否包含4
P1740
回复 1
|
赞 16
|
浏览 9.6k
#include<bits/stdc++.h> using namespace std; const int N=1e7+10; int vis[N]; int prime[N]; int cnt=0; int ans; //bool judge(int x){ // while(x){ // if(x%10==4) return true; // x/=10; //&nb...
题目
是(四)素数
题解数量
6
发布题解
在线答疑
热门题解
1
素数筛,然后再判断是否包含4
2
是(四)素数 题解:素数筛时限不过解决办法
3
是(四)素数 C语言题解:埃拉托斯特尼筛法
4
是(四)素数 题解:
5
是(四)素数 题解:埃氏筛 + string
6
是(四)素数 题解: