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