全MLE

P3383 【模板】线性筛素数

aszxqw @ 2024-10-22 14:10:21

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e8+10;
ll n,m,a[N],s[N];
bool zs(ll n){
    if(n<=1)return 0;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)return 0;
    }
    return 1;
}
int main(){
    std::ios::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        s[i]=zs(i);
    }
    sort(s+1,s+1+n);
    for(int i=1;i<=n;i++){
        cout<<s[a[i]]<<endl;
    }
    return 0;
}

by User_leo @ 2024-10-22 14:14:11

const ll N=1e8+10; ll n,m,a[N],s[N];

哥,您是认真的吗???

没事别乱开long long,谢


by xhq_5206 @ 2024-10-24 15:13:52

@aszxqw int is enough


by xhq_5206 @ 2024-10-24 15:17:05

@aszxqw but still TLE, bushixianxing


|