結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー tentententen
提出日時 2021-11-29 18:07:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,978 ms / 2,000 ms
コード長 1,623 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 74,464 KB
実行使用メモリ 74,552 KB
最終ジャッジ日時 2023-08-07 23:43:14
合計ジャッジ時間 23,371 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,978 ms
73,624 KB
testcase_01 AC 62 ms
57,364 KB
testcase_02 AC 59 ms
57,820 KB
testcase_03 AC 61 ms
58,052 KB
testcase_04 AC 61 ms
57,404 KB
testcase_05 AC 61 ms
57,288 KB
testcase_06 AC 61 ms
57,548 KB
testcase_07 AC 60 ms
57,312 KB
testcase_08 AC 59 ms
57,344 KB
testcase_09 AC 59 ms
57,532 KB
testcase_10 AC 63 ms
57,656 KB
testcase_11 AC 58 ms
57,332 KB
testcase_12 AC 58 ms
57,316 KB
testcase_13 AC 1,407 ms
72,332 KB
testcase_14 AC 1,410 ms
72,964 KB
testcase_15 AC 1,412 ms
72,896 KB
testcase_16 AC 1,405 ms
72,432 KB
testcase_17 AC 1,438 ms
73,856 KB
testcase_18 AC 837 ms
74,076 KB
testcase_19 AC 1,893 ms
74,552 KB
testcase_20 AC 494 ms
69,560 KB
testcase_21 AC 495 ms
69,864 KB
testcase_22 AC 1,731 ms
73,484 KB
testcase_23 AC 284 ms
63,912 KB
testcase_24 AC 274 ms
63,460 KB
testcase_25 AC 1,292 ms
74,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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 + 1];
        for (int i = 0; i < counts.length; i++) {
            ans[n - counts[i]] = i;
        }
        StringBuilder sb = new StringBuilder();
        int max = 0;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, ans[i]);
            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 next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0