1 条题解
-
0
思路
人数至5000,按倍数翻转状态,需区分初始开与最终关。按题面规定的输入输出协议处理;数据、边界和算法核验记录保存在本批教师资料。
参考程序(C++11)
#include <bits/stdc++.h> using namespace std; long long gcdll(long long a,long long b){while(b){long long t=a%b;a=b;b=t;}return a;} int main(){ios::sync_with_stdio(false);cin.tie(nullptr);const int p=1109; int n,m;cin>>n>>m;vector<bool>a(n+1,true);for(int k=1;k<=m;k++)for(int j=k;j<=n;j+=k)a[j]=!a[j];bool first=true;for(int i=1;i<=n;i++)if(!a[i]){if(!first)cout<<",";cout<<i;first=false;} cout<<"\n";return 0;}
- 1