From 53a7e445b8895485c5f1ded2dc97afece73847b9 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Wed, 19 Mar 2025 16:53:53 +0900 Subject: [PATCH] =?UTF-8?q?[20250319]=20BOJ=20/=20G4=20/=20=EC=88=98=20?= =?UTF-8?q?=EB=82=98=EB=88=84=EA=B8=B0=20=EA=B2=8C=EC=9E=84=20/=20?= =?UTF-8?q?=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\352\270\260 \352\262\214\354\236\204.md" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "suyeun84/202503/19 BOJ G4 \354\210\230 \353\202\230\353\210\204\352\270\260 \352\262\214\354\236\204.md" diff --git "a/suyeun84/202503/19 BOJ G4 \354\210\230 \353\202\230\353\210\204\352\270\260 \352\262\214\354\236\204.md" "b/suyeun84/202503/19 BOJ G4 \354\210\230 \353\202\230\353\210\204\352\270\260 \352\262\214\354\236\204.md" new file mode 100644 index 00000000..1f8fa557 --- /dev/null +++ "b/suyeun84/202503/19 BOJ G4 \354\210\230 \353\202\230\353\210\204\352\270\260 \352\262\214\354\236\204.md" @@ -0,0 +1,37 @@ +```java +import java.io.*; +import java.util.*; + +public class boj27172 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + + public static void main(String[] args) throws Exception { + nextLine(); + int N = nextInt(); + nextLine(); + int[] card = new int[N]; + int[] selected = new int[1000001]; + int[] answer = new int[N+1]; + for (int i = 0; i < N; i++) { + card[i] = nextInt(); + selected[card[i]] = i+1; + } + + for (int i = 0; i < N; i++) { + int start = card[i]; + for (int j = start*2; j < 1000001; j += start) { + if (selected[j] > 0) { + answer[selected[j]] -= 1; + answer[selected[start]] += 1; + } + } + } + for (int i = 1; i < N+1; i++) { + System.out.print(answer[i]+" "); + } + } +} +```