Baekjoon

[#2164] 카드 2

강람이 2020. 3. 15. 21:15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <queue>
 
using namespace std;
 
int main() {
    queue<int> q;
    int n;
    cin >> n;
 
    for (int i = 1; i <= n; i++) {
        q.push(i);  //일단 n까지 push
    }
 
    while (q.size() != 1) {
        q.pop();  //맨 위 카드 버리고
        q.push(q.front());  //맨 위 카드 밑으로 옮기고
        q.pop();  
    }
 
    cout << q.front() << "\n";
 
    return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs