Skip to content

Commit 25a9970

Browse files
authored
[20250204] BOJ / G5 / 입력숫자 / 설진영
1 parent 3190b13 commit 25a9970

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
public static void main(String[] args) throws IOException {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
StringTokenizer st;
9+
10+
int N = Integer.parseInt(br.readLine());
11+
int[] resultList = new int[N];
12+
int[] answerList = new int[N];
13+
14+
st = new StringTokenizer(br.readLine());
15+
for(int i = 0; i < N; i++) {
16+
resultList[i] = Integer.parseInt(st.nextToken());
17+
}
18+
19+
answerList[0] = resultList[0];
20+
int idx = answerList[0] % N;
21+
22+
for(int i = 1; i < N; i++) {
23+
while(answerList[idx] != 0) {
24+
idx = (idx + 1) % N;
25+
}
26+
answerList[idx] = resultList[i];
27+
idx = (idx + resultList[i]) % N;
28+
}
29+
30+
System.out.println(N);
31+
for(int x : answerList) {
32+
System.out.print(x + " ");
33+
}
34+
}
35+
}
36+
```

0 commit comments

Comments
 (0)