Skip to content

Commit

Permalink
[D3] Title: [S/W 문제해결 기본] 7일차 - 암호생성기, Time: 144 ms, Memory: 23,028 K…
Browse files Browse the repository at this point in the history
…B -BaekjoonHub
  • Loading branch information
sey2 committed Nov 13, 2023
1 parent 54d9b14 commit bf63853
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# [D3] [S/W 문제해결 기본] 7일차 - 암호생성기 - 1225

[문제 링크](https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14uWl6AF0CFAYD)

### 성능 요약

메모리: 23,028 KB, 시간: 144 ms, 코드길이: 1,267 Bytes

### 제출 일자

2023-11-14 02:05



> 출처: SW Expert Academy, https://swexpertacademy.com/main/code/problem/problemList.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Solution {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

// int t = Integer.parseInt(br.readLine());

for(int i=1; i<=10; i++) {
int n = Integer.parseInt(br.readLine());

String in[] = br.readLine().split(" ");
int arr[] = new int[8];

for(int j=0; j<in.length; j++)
arr[j] = Integer.parseInt(in[j]);

System.out.println("#" + i + " " + sol(arr));
}
}

public static String sol(int arr[]) {
Queue<Integer> q = new LinkedList<>();

for(int i=0; i<arr.length; i++)
q.add(arr[i]);

int cnt = 1;
boolean run = true;

while(run) {
int num = q.poll() - cnt++;
if(num <= 0) {
num = 0;
run = false;
}
q.add(num);
if(cnt == 6) cnt = 1;
}

String ans = "";
for(int i=0; i<arr.length; i++) {
ans += q.poll() + " ";
}

return ans.trim();
}

}

0 comments on commit bf63853

Please sign in to comment.