Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
79101 段文昊 【一维数组】约瑟夫问题 C++ Accepted 1 MS 276 KB 319 2024-06-30 11:47:56

Tests(3/3):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int n,m,s=0; cin>>n>>m; queue<int>ren; for(int i=1;i<=n;i++){ ren.push(i); } while(ren.size()!=1){ int r=ren.front(); ren.pop(); s++; if(s==m){ s=0; } else{ ren.push(r); } } cout<<ren.front(); return 0; }