20251118 baekjoon
This commit is contained in:
parent
5737de5c2b
commit
ea8ee29090
30
code_study/Baekjoon/java/_27172.java
Normal file
30
code_study/Baekjoon/java/_27172.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class _27172 {
|
||||||
|
static int MAX_N = 1000001;
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
int N = Integer.parseInt(sc.nextLine());
|
||||||
|
int[] nums = Arrays.stream(sc.nextLine().split(" "))
|
||||||
|
.mapToInt(Integer::parseInt)
|
||||||
|
.toArray();
|
||||||
|
sc.close();
|
||||||
|
|
||||||
|
int[] scores = new int[MAX_N];
|
||||||
|
boolean[] cards = new boolean[MAX_N];
|
||||||
|
for (int n : nums) {
|
||||||
|
cards[n] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<N; i++) {
|
||||||
|
for(int n=nums[i]*2; n<MAX_N; n+=nums[i]) {
|
||||||
|
if(cards[n]) {
|
||||||
|
scores[nums[i]]++;
|
||||||
|
scores[n]--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int n: nums) System.out.printf("%d ", scores[n]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user