比赛 | 板子大赛 | 评测结果 | AAAAA |
---|---|---|---|
题目名称 | 约瑟夫问题 | 最终得分 | 100 |
用户昵称 | 李奇文 | 运行时间 | 0.018 s |
代码语言 | C++ | 内存使用 | 3.27 MiB |
提交时间 | 2025-01-22 15:08:37 | ||
#include<bits/stdc++.h> using namespace std; int n,m,s=0; bool f[200]={0}; int main(){ freopen("ysf.in","r",stdin); freopen("ysf.out","w",stdout); std::cin>>n>>m; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(++s>n) s=1; if(f[s]) j--; } std::cout<<s<<endl; f[s]=true; } return 0; }