QwQ,蒟蒻求助,全TLE,(肯定哪没考虑到(((
查看原帖
QwQ,蒟蒻求助,全TLE,(肯定哪没考虑到(((
935012
Max6700楼主2023/6/14 19:47
#include<bits/stdc++.h>
using namespace std;

int a[20000000];
int n,m;
int main(){
    std::ios::sync_with_stdio(0);
    cin>>n>>m;
    a[0]=a[1]=1;
    for(int i=2;i*2<=1e7;i++)
        if(a[i]==0)for(int j=i*2;j<=1e7;j++)
            a[j]=1;
    
    for(int i=1;i<=m;i++)
    {
        int x;
        cin>>x;
        int y=1;
        while(x)
        {
            y++;
            if(!a[y])x--;
        }
        cout<<y<<"\n";
    }
    return 0;
}

挺乱的

2023/6/14 19:47
加载中...