結果
問題 | No.1730 GCD on Blackboard in yukicoder |
ユーザー | tenten |
提出日時 | 2023-03-27 11:03:15 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,987 ms / 2,000 ms |
コード長 | 2,197 bytes |
コンパイル時間 | 2,552 ms |
コンパイル使用メモリ | 91,544 KB |
実行使用メモリ | 67,876 KB |
最終ジャッジ日時 | 2023-10-19 14:02:06 |
合計ジャッジ時間 | 23,814 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,987 ms
67,876 KB |
testcase_01 | AC | 71 ms
58,720 KB |
testcase_02 | AC | 73 ms
58,288 KB |
testcase_03 | AC | 73 ms
58,696 KB |
testcase_04 | AC | 69 ms
58,176 KB |
testcase_05 | AC | 76 ms
58,292 KB |
testcase_06 | AC | 70 ms
58,192 KB |
testcase_07 | AC | 74 ms
58,300 KB |
testcase_08 | AC | 66 ms
58,288 KB |
testcase_09 | AC | 65 ms
58,280 KB |
testcase_10 | AC | 76 ms
58,192 KB |
testcase_11 | AC | 69 ms
58,736 KB |
testcase_12 | AC | 71 ms
58,296 KB |
testcase_13 | AC | 1,405 ms
65,032 KB |
testcase_14 | AC | 1,439 ms
65,432 KB |
testcase_15 | AC | 1,437 ms
65,552 KB |
testcase_16 | AC | 1,432 ms
65,032 KB |
testcase_17 | AC | 1,435 ms
65,340 KB |
testcase_18 | AC | 832 ms
66,132 KB |
testcase_19 | AC | 1,906 ms
65,252 KB |
testcase_20 | AC | 509 ms
64,116 KB |
testcase_21 | AC | 495 ms
64,004 KB |
testcase_22 | AC | 1,747 ms
67,780 KB |
testcase_23 | AC | 285 ms
63,776 KB |
testcase_24 | AC | 265 ms
64,544 KB |
testcase_25 | AC | 1,301 ms
66,076 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[] values = new int[n + 1]; for (int i = 1; i <= 1000000; i++) { values[counts[i]] = i; } int current = 0; StringBuilder sb = new StringBuilder(); for (int i = n; i > 0; i--) { current = Math.max(current, values[i]); sb.append(current).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(); } }