1 条题解

  • 0
    @ 2026-9-11 19:43:28

    时间有点离谱......

    #include <bits/stdc++.h>
    using namespace std;
    const int M=20000000;
    vector<bool> is(M+1,1);
    vector<int> p;
    void sieve(){
        is[0]=is[1]=0;
        for(int i=2;i<=M;i++){
            if(is[i]){
                p.push_back(i);
                if((long long)i*i<=M){
                    for(int j=i*i;j<=M;j+=i) {
                        is[j]=0;
                    }
                }
            }
        }
    }
    signed main(){
        ios::sync_with_stdio(0);cin.tie(0);
        sieve();
        int n;
        if(cin>>n) {
            if(n>0&&n<=p.size()) {
                cout<<p[n-1]<<endl;
            }
    		else{
                cerr<<"Range exceeded, increase MAX_LIMIT"<<endl;
            }
        }
        return 0;
    }
    
    • 1

    信息

    ID
    103
    时间
    1000ms
    内存
    256MiB
    难度
    1
    标签
    递交数
    65
    已通过
    43
    上传者