-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[D3] Title: [S/W 문제해결 기본] 7일차 - 암호생성기, Time: 144 ms, Memory: 23,028 K…
…B -BaekjoonHub
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
53 changes: 53 additions & 0 deletions
53
SWEA/D3/1225. [S/W 문제해결 기본] 7일차 - 암호생성기/[S/W 문제해결 기본] 7일차 - 암호생성기.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} | ||
|