Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
79098 殷震轩 【一维数组】约瑟夫问题 C++ Accepted 1 MS 272 KB 318 2024-06-30 11:44:05

Tests(3/3):


Code:

#include<bits/stdc++.h> using namespace std; queue<long long> a; 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 r=a.front(); a.pop(); s++; if(s==m){ s=0; }else{ a.push(r); } } cout<<a.front(); return 0; }