#include <iostream>
#include <queue>
using namespace std;
int main() {
int n,k,m;
cin>>n>>k>>m;
queue<int> q;
for(int i=0;i<n;i++) q.push(i);
queue<int> t;
while(q.front()!=k) {
t.push(q.front());
q.pop();
}//找到第一个报数的编号
while(!t.empty()){
q.push(t.front());
t.pop();
}
while(1){
int a;
for(int i=1;i<=m;i++){
if(i==m) {
q.pop();
}
else {
a= q.front();
q.pop();
q.push(a);//将第一个数,放到最后一个
}
}
if(q.size()==1) break;
}
cout<<q.front()<<endl;
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号