1 분 소요

🗒️ 2164번) 카드2

#include <iostream>
#include <queue>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;

	queue<int> q;
	for (int n = 1; n <= N; n++)
		q.push(n);
	
	while (q.size() > 1)
	{
		q.pop();
		int top = q.front();
		q.pop();
		q.push(top);
	}

	cout << q.front();
	
	return 0;
}

카테고리:

업데이트:

댓글남기기