문제 링크 : https://www.acmicpc.net/problem/2164
맞힌 코드
#include <bits/stdc++.h>
using namespace std;
int n;
int main(void){
cin >> n;
queue<int> q;
for (int i=0; i<n; i++){
q.push(i+1);
}
int answer;
answer = q.front();
q.pop();
while (!q.empty()){
answer = q.front();
int temp = q.front();
q.pop();
q.push(temp);
q.pop();
}
cout << answer << '\n';
}
'Algorithm' 카테고리의 다른 글
[백준/BOJ] 14888번 연산자 끼워넣기 C++ (0) | 2025.01.26 |
---|---|
[백준/BOJ] 25757번 임스와 함께하는 미니게임 C++ (0) | 2025.01.23 |
[프로그래머스] 42577번 전화번호 목록 C++ (0) | 2024.11.15 |
[프로그래머스] 42842번 카펫 C++ (0) | 2024.11.13 |
[프로그래머스] 42839번 소수 찾기 C++ (0) | 2024.11.13 |