-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path1225_암호생성기.cpp
47 lines (38 loc) · 975 Bytes
/
1225_암호생성기.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <queue>
using namespace std;
int main(int argc, char** argv)
{
int k, T = 10;
queue<int> q;
for (int test_case = 1; test_case <= T; ++test_case) {
cin >> test_case;
for (int i = 0; i < 8; i++) {
cin >> k;
q.push(k);
}
int cycle = 1;
while (1) {
int now = q.front() - cycle;
q.pop();
// 0보다 작아지거나 0일 경우 0 저장하고 종료
if (now <= 0) {
q.push(0);
break;
}
q.push(now);
cycle++;
// 사이클이 끝나면 다시 1부터 시작
if (cycle > 5)
cycle = 1;
}
cout << "#" << test_case << " ";
// 암호 출력
while (!q.empty()) {
cout << q.front() << " ";
q.pop();
}
cout << "\n";
}
return 0;
}