BOJ 2164 카드2

1 개요[ | ]

BOJ 2164 카드2


2 C++[ | ]

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, temp;
    cin >> N;
    queue<int> q;
    for(int i=1; i<=N; i++) {
        q.push(i);
    }
    while(true) {
        if(q.size()<2) break;
        q.pop();
        if(q.size()<2) break;
        temp = q.front();
        q.pop();
        q.push(temp);
    }
    cout << q.front();
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}