하다보니
2164번-카드2 본문
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
queue<int> Q;
int n;
cin >> n;
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();
}
'알고리즘 풀이 > 백준' 카테고리의 다른 글
1021번-회전하는 큐 (0) | 2022.01.23 |
---|---|
10866번-덱 (0) | 2022.01.23 |
10845번-큐 (0) | 2022.01.23 |
2493번-탑 (0) | 2022.01.22 |
1874번-스택 수열 (0) | 2022.01.22 |