結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー tentententen
提出日時 2023-07-19 09:21:26
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,181 bytes
コンパイル時間 3,067 ms
コンパイル使用メモリ 92,092 KB
実行使用メモリ 67,920 KB
最終ジャッジ日時 2023-10-19 11:58:01
合計ジャッジ時間 11,238 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 76 ms
58,876 KB
testcase_02 AC 74 ms
58,372 KB
testcase_03 AC 80 ms
59,128 KB
testcase_04 AC 79 ms
59,084 KB
testcase_05 AC 86 ms
59,004 KB
testcase_06 AC 78 ms
58,860 KB
testcase_07 AC 87 ms
58,904 KB
testcase_08 AC 77 ms
58,868 KB
testcase_09 AC 72 ms
58,368 KB
testcase_10 AC 96 ms
59,544 KB
testcase_11 AC 74 ms
58,364 KB
testcase_12 AC 87 ms
58,368 KB
testcase_13 AC 1,477 ms
65,168 KB
testcase_14 AC 1,482 ms
65,404 KB
testcase_15 AC 1,562 ms
66,792 KB
testcase_16 AC 1,474 ms
65,224 KB
testcase_17 AC 1,478 ms
66,432 KB
testcase_18 AC 850 ms
65,828 KB
testcase_19 AC 1,927 ms
66,312 KB
testcase_20 AC 543 ms
64,416 KB
testcase_21 AC 535 ms
64,424 KB
testcase_22 AC 1,787 ms
67,884 KB
testcase_23 AC 278 ms
63,476 KB
testcase_24 AC 302 ms
64,972 KB
testcase_25 AC 1,322 ms
66,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] counts = new int[1000001];
        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 = 1; i < counts.length; i++) {
            ans[n - counts[i]] = i;
        }
        int max = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            max = Math.max(max, ans[i]);
            sb.append(max).append("\n");
        }
        System.out.print(sb);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0