队列写法,90%通过率,求优化
#include <bits/stdc++.h>
using namespace std;
queue<int> a;
void solve()
{
int n , k , m , x;
cin >> n >> k >> m;
for(int i = 1 ; i <= n ; i++) a.push(i);
for(int i = 1 ; i < k ; i++){
x = a.front();
a.push(x);
a.pop();
}
while(a.size() != 1){
for(int i = 1 ; i < m ; i++)
{
x = a.front();
a.push(x);
a.pop();
}
a.pop();
}
cout << a.front();
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t = 1;
//cin >> t;
while(t--)
{
solve();
}
return 0;
}