Skip to content

Commit 53a7e44

Browse files
authored
[20250319] BOJ / G4 / 수 나누기 게임 / 김수연
1 parent 2f82115 commit 53a7e44

File tree

1 file changed

+37
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)