문제출처 : https://www.acmicpc.net/problem/11866
code
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main()
{
int N, K, x;
vector <int>v;
queue<int> q;
cin >> N >> K;
for (int i = 1; i <= N; i++)
q.push(i);
while (!q.empty())
{
for (int i = 0; i < K-1; i++)
{
x = q.front();
q.pop();
q.push(x);
}
x = q.front();
q.pop();
v.push_back(x);
}
cout << "<";
for (int i = 0; i < N; i++)
{
if (i != N - 1)
cout << v[i] << ", ";
else
cout << v[i];
}
cout << ">";
return 0;
}
원형큐 문제로 푸쉬와 팝을 적절하게만 쓰면 쉬운문제다.