File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments