Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
79099 | 李琥博 | 【一维数组】约瑟夫问题 | C++ | Accepted | 1 MS | 272 KB | 303 | 2024-06-30 11:44:49 |
#include<bits/stdc++.h> using namespace std; queue<int> a,t; int main(){ int n,m,s=0; cin>>n>>m; for(int i=1;i<=n;i++){ a.push(i); } while(a.size()!=1){ int sr=a.front(); a.pop(); s++; if(s==m){ s=0; }else{ a.push(sr); } } cout<<a.front(); return 0; }