| 比赛 | 板子大赛 | 评测结果 | AAAAA |
|---|---|---|---|
| 题目名称 | 约瑟夫问题 | 最终得分 | 100 |
| 用户昵称 | 梧叶已同秋雨去 | 运行时间 | 0.016 s |
| 代码语言 | C++ | 内存使用 | 3.33 MiB |
| 提交时间 | 2025-01-22 16:28:08 | ||
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[105];
int main(){
freopen("ysf.in","r",stdin);
freopen("ysf.out","w",stdout);
cin>>n>>k;
int f=0,h=0,t=1;
while(t<=n){
h++;
if(h==n+1){
h=1;
}
if(a[h]==0){
f++;
}
if(f==k){
cout<<h<<"\n";
a[h]=-1;
f=0;
t++;
}//cout<<h<<endl;
//cout<<h<<" "<<f<<endl;
}
return 0;
}