https://www.acmicpc.net/problem/2164
문제의 규칙에 따라 큐에서 pop하고 push하며, 큐의 크기가 1이면 반복을 중단한다.
#include <iostream>
#include <queue>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int n;
cin >> n;
queue<int> q;
for(int i=1; i<=n; i++) q.push(i);
while(q.size() != 1) {
q.pop();
q.push(q.front());
q.pop();
}
cout << q.front();
return 0;
}