#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
 
int main(void)
{
//    freopen("B2161_input.txt", "r", stdin);
    
    queue<int> q;
    int N;
    
    cin >> N;
    
    for(int i = 1; i <= N; i++)
    {
        q.push(i);
    }
    
    while(q.size() != 1)
    {
        // 우선, 제일 위에 있는 카드를 바닥에 버린다.
        q.pop();
        
        
        // 그 다음, 제일 위에 있는 카드를 제일 아래에 있는 카드 밑으로 옮긴다.
        int temp = q.front();
        q.pop();
        q.push(temp);
    }
    
    cout << q.front();
    
    return 0;
}
cs

+ Recent posts