https://www.acmicpc.net/problem/1158
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <iostream> #include <stdio.h> #include <deque> #pragma warning (disable : 4996) using namespace std; int main() { deque<int> deq; int N, M; cin >> N >> M; for (int i = 1; i <= N; i++) deq.push_back(i); printf("<"); int del; while (!deq.empty()) { for (int i = 0; i < M; i++) { del = deq.front(); deq.pop_front(); if (i != M - 1) deq.push_back(del); } if (!deq.empty()) printf("%d, ", del); else printf("%d", del); } printf(">"); return 0; } | cs |
'Algorithm Problems > BOJ' 카테고리의 다른 글
[11657번] Time Machine 타임머신 - Bellman-Ford Algorithm[C++]☆ (0) | 2017.01.17 |
---|---|
[9935번] String Explosion 문자열 폭발 - Stack[C++] ☆ (0) | 2017.01.03 |
[5397번] Keylogger 키로거 - Stack[C++] (0) | 2017.01.02 |
[10817번] Three Interger 세 수 - if condition[C++] (0) | 2017.01.02 |
[11721번] Print out per ten lines 열개씩 끊어 출력하기 - For Loop [C++] ☆ (0) | 2016.12.29 |