Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
79262 邓昊源 【一维数组】约瑟夫问题 C++ Accepted 0 MS 276 KB 329 2024-06-30 16:53:55

Tests(3/3):


Code:

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