选大王

 1 #include <iostream>
 2 #include <algorithm>
 3 using namespace std;
 4 
 5 int main(){
 6     int n, m;
 7     while (cin >> n >> m){
 8         int ans = 0;
 9         for (int i = 2; i <= n; i++){
10             ans = (ans + m) % i;
11         }
12         cout << ans + 1 << endl;
13     }
14 
15     return 0;
16 }
原文地址:https://www.cnblogs.com/ouyang_wsgwz/p/8516926.html