Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
79286 何嘉乐 【一维数组】约瑟夫问题 C++ Accepted 1 MS 280 KB 341 2024-06-30 17:19:02

Tests(3/3):


Code:

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