20251118 baekjoon

This commit is contained in:
songyc macbook 2025-11-18 21:24:01 +09:00
parent 5737de5c2b
commit ea8ee29090

View 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]);
}
}