Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
63535 孙诗皓 猴子选大王 C++ Accepted 2 MS 280 KB 564 2024-01-13 17:42:51

Tests(10/10):


Code:

#include<iostream> #include<cstring> #include<algorithm> using namespace std; int main(){ int n,m,ge=0,xu=0,bao=1; cin>>n>>m; int a[n+1]; for(int i=1;i<=n;i++) a[i]=1; while(ge!=n-1) { xu++; if(xu==n+1) xu=1; if(a[xu]==0) continue; if(bao==m) { a[xu]=0; bao=0; ge++; } bao++; } for(int i=1;i<=n;i++) { if (a[i]==1) cout<<i; } return 0; }