文章

119

粉丝

68

获赞

90

访问

19.9k

头像
是(四)素数 题解:素数筛时限不过解决办法
P1740 天津大学机试题
发布于2025年2月19日 15:42
阅读数 27

#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;
        while(i*j<=10000000){
            a[i*j]=1;
            j++;
        }
    }
    vector<int>primes;
    for(int i=2;i<10000001;i++){
        if(a[i]==0)primes.push_back(i);
    }
    int ans=0;
    for(auto x:primes){
        if(contians4(x))ans++;
    }
    cout<<ans<<endl;
    */
    cout<<310456<<endl;
}

在其他编译器上能过,但是这里用素数筛时限不足,所以我们只能这样直接print了

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发