結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー tentententen
提出日時 2021-11-08 12:29:58
言語 Java19
(openjdk 21)
結果
AC  
実行時間 1,985 ms / 2,000 ms
コード長 1,738 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 74,604 KB
実行使用メモリ 74,192 KB
最終ジャッジ日時 2023-08-07 23:37:44
合計ジャッジ時間 23,627 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,985 ms
73,428 KB
testcase_01 AC 62 ms
58,312 KB
testcase_02 AC 61 ms
57,732 KB
testcase_03 AC 61 ms
57,776 KB
testcase_04 AC 63 ms
57,440 KB
testcase_05 AC 62 ms
57,400 KB
testcase_06 AC 61 ms
57,432 KB
testcase_07 AC 62 ms
57,416 KB
testcase_08 AC 62 ms
57,468 KB
testcase_09 AC 60 ms
57,420 KB
testcase_10 AC 64 ms
58,172 KB
testcase_11 AC 59 ms
57,536 KB
testcase_12 AC 60 ms
57,464 KB
testcase_13 AC 1,423 ms
72,636 KB
testcase_14 AC 1,423 ms
72,676 KB
testcase_15 AC 1,464 ms
74,192 KB
testcase_16 AC 1,420 ms
72,812 KB
testcase_17 AC 1,478 ms
72,156 KB
testcase_18 AC 833 ms
73,592 KB
testcase_19 AC 1,897 ms
72,928 KB
testcase_20 AC 500 ms
69,832 KB
testcase_21 AC 494 ms
70,188 KB
testcase_22 AC 1,731 ms
73,756 KB
testcase_23 AC 279 ms
63,288 KB
testcase_24 AC 272 ms
63,748 KB
testcase_25 AC 1,294 ms
73,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] counts = new int[2000001];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            for (int j = 1; j <= Math.sqrt(x); j++) {
                if (x % j == 0) {
                    counts[j]++;
                    if (j * j < x) {
                        counts[x / j]++;
                    }
                }
            }
        }
        int[] ans = new int[n];
        for (int i = 1; i < counts.length; i++) {
            if (counts[i] > 0) {
                ans[n - counts[i]] = i;
            }
        }
        int max = 0;
        StringBuilder sb = new StringBuilder();
        for (int x : ans) {
            max = Math.max(x, max);
            sb.append(max).append("\n");
        }
        System.out.print(sb);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0