Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
79283 | 邸礼诚 | 【一维数组】约瑟夫问题 | C++ | Accepted | 0 MS | 280 KB | 350 | 2024-06-30 17:13:56 |
#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; }