https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14uWl6AF0CFAYD&
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
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();
}
}