比赛 | 板子大赛 | 评测结果 | AAAAA |
---|---|---|---|
题目名称 | 约瑟夫问题 | 最终得分 | 100 |
用户昵称 | chenbp | 运行时间 | 0.017 s |
代码语言 | C++ | 内存使用 | 3.27 MiB |
提交时间 | 2025-01-22 09:48:07 | ||
#include <iostream> #include <cstdio> using namespace std; bool a[105]; int main(){ freopen("ysf.in","r",stdin); freopen("ysf.out","w",stdout); int n,k; cin>>n>>k; int now=0; for(int i=1;i<=n;i++){ int tot=0; int s=k%(n-i+1); if(s==0) s=n-i+1; while(tot<s){ now++; if(now>n) now=1; if(!a[now]) tot++; } a[now]=1; cout<<now<<endl; } return 0; }