2 solutions

  • 0
    @ 2024-11-29 19:26:53

    #include<bits/stdc++.h> using namespace std; const int N=1e7; int a[N]; int main() { int n,m,i,t,cnt=0; cin>>n>>m; for(i=1;i<=n;i++){ a[i]=0; } for(t=2;t<=m;t++){ for(i=t;i<=n;i=i+t){ if(a[i]==0){ a[i]=1; }else if(a[i]==1){ a[i]=0; } } } for(i=1;i<=n;i++){ if(a[i]0){ if(cnt0){ cout<<i; cnt++; } else{ cout<<","<<i; } } } return 0; }

    Information

    ID
    6772
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    8
    Tags
    (None)
    # Submissions
    186
    Accepted
    33
    Uploaded By