https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14uWl6AF0CFAYD&
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;
public class Solution {
public static void main (String[] args) {
Scanner scanner = new Scanner(System.in);
for (int t = 1; t <= 10; t++) {
int T = scanner.nextInt();
Queue<Integer> queue = new LinkedList<>();
for (int i = 0; i < 8; i++) // 데이터 8개 입력
queue.offer(scanner.nextInt());
int sub = 0;
while (true) {
if(sub == 5)
sub = 0;
int num = queue.poll() - (++sub);
if (num <= 0) {
queue.offer(0);
break;
}
queue.offer(num);
}
System.out.print("#" + T + " ");
while (!queue.isEmpty())
System.out.print(queue.poll() + " ");
System.out.println();
}
scanner.close();
}
}
'Algorithm > 백준+프로그래머스+SWEA+정올+구름' 카테고리의 다른 글
[Algorithm] SWEA 1861 정사각형 방 (0) | 2021.08.06 |
---|---|
[Algorithm] SWEA 1940 가랏! RC카! (0) | 2021.08.05 |
[Algorithm] SWEA 1218 괄호짝짓기 (0) | 2021.08.05 |
[Algorithm] 백준 2493 탑 (0) | 2021.08.05 |
[Algorithm] 백준 5622 다이얼 (0) | 2021.08.04 |