文章

13

粉丝

0

获赞

32

访问

1.4k

头像
是(四)素数 题解:
P1740 天津大学机试题
发布于2026年3月14日 00:24
阅读数 96

#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[++prime[0]]=i;
        for(int j=1;j<=prime[0]&&prime[j]*i<maxn;j++){
            prime[prime[j]*i]=1;
            if(i%prime[j]==0) break;
        }
    }
}
bool panduan_4(int x){
    while(x>0){
        if(x%10==4) return true;
        x/=10;
    }
    return false;

int main()
{
    getprime();//素数筛选预处理
    int count=0;//计数器 
    for(...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发