Notice
Recent Posts
Recent Comments
Link
Programmer
1158 요세푸스 문제 본문
#include <iostream>
#include <list>
using namespace std;
void solve() {
list<int> itemList;
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++)
itemList.push_back(i + 1);
cout << "<";
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < k - 1; j++) {
itemList.push_back(itemList.front());
itemList.pop_front();
}
cout << itemList.front() << ", ";
itemList.pop_front();
}
cout << itemList.front() << ">\n";
}
int main() {
solve();
return 0;
}
'백준' 카테고리의 다른 글
1181번 단어 정렬 (0) | 2020.04.11 |
---|---|
3986번 좋은 단어 (0) | 2020.04.04 |
10828번 스택 (0) | 2020.04.03 |
10845번 큐 (0) | 2020.04.02 |
Comments