#include <iostream>#include <queue>#include <string>using namespace std;void Josephus(int n, int m);int main(){int n, m;cin >> n >> m;Josephus(n, m);return 0;}void Josephus(int n, int m){queue<int> q;int i;for (i = 1; i <= n; i++)q.push(i);cout << "<";while (!q.empty()){for (i = 0; i < m - 1; i++){q.push(q.front());q.pop();}cout << q.front();q.pop();if (!q.empty())cout << ", ";}cout << ">\n";return;}
'백준' 카테고리의 다른 글
| [1021] 회전하는 큐 (0) | 2018.07.22 |
|---|---|
| [10866] 덱 (0) | 2018.07.22 |
| [1966] 프린터 큐 (0) | 2018.07.22 |
| [10845] 큐 (0) | 2018.07.22 |
| [2504] 괄호의 값 (0) | 2018.07.22 |