結果
問題 | No.1730 GCD on Blackboard in yukicoder |
ユーザー | tenten |
提出日時 | 2023-07-19 09:16:57 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,213 bytes |
コンパイル時間 | 3,424 ms |
コンパイル使用メモリ | 96,056 KB |
実行使用メモリ | 67,684 KB |
最終ジャッジ日時 | 2023-10-19 11:52:14 |
合計ジャッジ時間 | 25,133 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | AC | 82 ms
58,304 KB |
testcase_02 | AC | 72 ms
58,820 KB |
testcase_03 | AC | 74 ms
58,832 KB |
testcase_04 | AC | 74 ms
58,788 KB |
testcase_05 | AC | 75 ms
58,568 KB |
testcase_06 | AC | 75 ms
58,820 KB |
testcase_07 | AC | 85 ms
58,808 KB |
testcase_08 | AC | 81 ms
58,812 KB |
testcase_09 | AC | 74 ms
58,600 KB |
testcase_10 | AC | 83 ms
59,052 KB |
testcase_11 | AC | 74 ms
58,632 KB |
testcase_12 | AC | 74 ms
58,640 KB |
testcase_13 | AC | 1,447 ms
64,936 KB |
testcase_14 | AC | 1,451 ms
65,056 KB |
testcase_15 | AC | 1,457 ms
65,648 KB |
testcase_16 | AC | 1,585 ms
65,644 KB |
testcase_17 | AC | 1,456 ms
66,276 KB |
testcase_18 | AC | 826 ms
66,264 KB |
testcase_19 | AC | 1,922 ms
65,092 KB |
testcase_20 | AC | 508 ms
64,348 KB |
testcase_21 | AC | 501 ms
64,200 KB |
testcase_22 | AC | 1,759 ms
67,600 KB |
testcase_23 | AC | 288 ms
64,076 KB |
testcase_24 | AC | 288 ms
63,928 KB |
testcase_25 | AC | 1,317 ms
65,040 KB |
ソースコード
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++) { ans[i] = Math.max(max, ans[i]); max = ans[i]; sb.append(ans[i]).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(); } }