Baekjoon 2164
카드2


QUESTION ❔



CODE ⌨️

#include <iostream>
#include <deque>

using namespace std;
deque<int> DQ;

int N;
int cnt = 1;

int result;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> N;

	for (int i = 1; i <= N; i++)
	{
		DQ.push_back(i);
	}

	while (!DQ.empty())
	{
		result = DQ.front();
		DQ.pop_front();

		if (cnt % 2 == 1)
		{
			cnt++;
		}
		else
		{
			DQ.push_back(result);
			cnt++;
		}
	}

	cout << result << "\n";

	return 0;
}



RESULT 💛



SIMPLE DISCUSSION ✏️

구현 관련 문제였다.



SOURCE 💎

Baekjoon_Link 👈 Click here


*****
NOT A TALENT ❎ NOT GIVING UP ✅
CopyRight ⓒ 2022 DCherish All Rights Reserved.