슈콩

[SWEA] 7일차 - 암호생성기 본문

Algorithms/SWEA

[SWEA] 7일차 - 암호생성기

shukong 2025. 11. 9. 15:32

 

 

[문제]

http://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14uWl6AF0CFAYD

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

 

[소스 코드]

import java.util.*;
import java.io.*;
public class Solution {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		for(int tc=1;tc<=10;tc++) {
			int t = Integer.parseInt(br.readLine());
			Queue<Integer> q = new LinkedList<>();
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<8;i++) {
				q.offer(Integer.parseInt(st.nextToken()));
			}
			boolean check = false;
			while(true) {
				for(int i=1;i<=5;i++) {
					int n = q.poll();
					if(n-i<=0) {
						check = true;
						q.offer(0);
						break;
					}
					else {
						q.offer(n-i);
					}
				}
				if(check) break;
			}
			System.out.print("#"+tc+" ");
			while(!q.isEmpty()) {
				System.out.print(q.poll()+" ");
			}
			System.out.println();
		}
	}
}

'Algorithms > SWEA' 카테고리의 다른 글

[SWEA] 단순 2진 암호코드  (0) 2025.11.09
[SWEA] 오목 판정  (0) 2025.11.09
[SWEA] 재미있는 오셀로 게임  (3) 2025.11.07
[SWEA] 진기의 최고급 붕어빵  (0) 2025.11.06
[SWEA] 3일차 - 회문 2  (0) 2025.11.06