Algorithm/백준
C++ 알고리즘 - 백준 2164 카드2
마루설아
2024. 12. 30. 20:19
https://www.acmicpc.net/problem/2164
#include <iostream>
#include <deque>
#define endl "\n"
using namespace std;
int main(void) {
// C++ Init
ios::sync_with_stdio(false);
cin.tie(NULL);
int input;
int temp;
deque<int> v;
cin >> input;
for (int i = 1; i <= input; i++) {
v.push_back(i);
}
while (v.size() != 1) {
v.pop_front();
temp = v.front();
v.pop_front();
v.push_back(temp);
}
cout << v[0] << endl;
}