Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
79267 | 杨莹斌 | 【一维数组】约瑟夫问题 | C++ | Accepted | 1 MS | 280 KB | 385 | 2024-06-30 17:01:52 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin >> n >> m; queue<int> live; for(int i = 1;i <= n;i++){ live.push(i); } int bs = 0; while(live.size()!=1){ int ren = live.front(); live.pop(); bs++; if(bs == m){ bs=0; }else{ live.push(ren); } } cout<<live.front(); live.pop(); return 0; }