1225 암호생성기
2020. 2. 5. 16:54ㆍLearn/Algorithm
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
|
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int tc = 1; tc<11; tc++) {
int arr[] = new int[9];
int v = sc.nextInt();
Queue<Integer> qu = new LinkedList<Integer>();
for(int i = 0; i < 8; i++) {
int e = sc.nextInt();
qu.add(e);
}
int a = qu.peek();
int cnt = 1;
while(true) {
a = qu.peek();
qu.poll();
a -= cnt;
if(cnt == 5)
cnt = 0;
cnt++;
if(a <= 0) {
qu.add(0);
break;
}
qu.add(a);
}
System.out.print("#" + v + " ");
for(int i : qu) {
System.out.print(i + " ");
}
System.out.println();
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
큐 이용 기본
'Learn > Algorithm' 카테고리의 다른 글
6603번 로또 - 백트레킹 (0) | 2020.02.06 |
---|---|
14888 연산자 끼워넣기 - 완전탐색,백트래킹 (0) | 2020.02.06 |
7576 토마토 (0) | 2020.02.04 |
2178번 미로 탐색 (0) | 2020.02.04 |
1012 유기농 배추 (0) | 2020.02.04 |