본문 바로가기
알고리즘

백준 s4 2164 카드2 c++

by kyj0032 2024. 1. 10.

https://www.acmicpc.net/problem/2164

 

/*boj s4 2164 카드2*/
#include <iostream>
#include <queue>

using namespace std;

int N;

int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    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() << '\n';
}

'알고리즘' 카테고리의 다른 글

백준 g5 5430 AC c++  (0) 2024.01.11
백준 s4 1021 회전하는 큐 c++  (0) 2024.01.11
백준 g5 2493 탑 c++  (0) 2024.01.10
백준 s2 1874 스택수열 c++  (0) 2024.01.10
c++ 4. 연결리스트 연습문제  (0) 2024.01.10