Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
79264 | 周梓易 | 【一维数组】约瑟夫问题 | C++ | Accepted | 1 MS | 276 KB | 334 | 2024-06-30 16:54:49 |
#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(); return 0; }