結果

問題 No.736 約比
ユーザー tentententen
提出日時 2020-09-02 10:26:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 2,319 ms
コンパイル使用メモリ 75,368 KB
実行使用メモリ 42,096 KB
最終ジャッジ日時 2024-05-01 10:28:17
合計ジャッジ時間 13,553 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
41,224 KB
testcase_01 AC 143 ms
41,412 KB
testcase_02 AC 142 ms
41,472 KB
testcase_03 AC 144 ms
41,688 KB
testcase_04 AC 145 ms
41,592 KB
testcase_05 AC 137 ms
41,408 KB
testcase_06 AC 132 ms
41,512 KB
testcase_07 AC 145 ms
41,708 KB
testcase_08 AC 143 ms
41,784 KB
testcase_09 AC 141 ms
41,824 KB
testcase_10 AC 145 ms
41,360 KB
testcase_11 AC 145 ms
41,320 KB
testcase_12 AC 144 ms
41,488 KB
testcase_13 AC 145 ms
41,400 KB
testcase_14 AC 138 ms
41,384 KB
testcase_15 AC 147 ms
41,728 KB
testcase_16 AC 144 ms
41,636 KB
testcase_17 AC 149 ms
41,252 KB
testcase_18 AC 146 ms
41,552 KB
testcase_19 AC 144 ms
41,404 KB
testcase_20 AC 141 ms
41,652 KB
testcase_21 AC 145 ms
41,728 KB
testcase_22 AC 133 ms
41,292 KB
testcase_23 AC 132 ms
41,224 KB
testcase_24 AC 140 ms
41,348 KB
testcase_25 AC 130 ms
41,596 KB
testcase_26 AC 132 ms
41,472 KB
testcase_27 AC 147 ms
41,804 KB
testcase_28 AC 144 ms
41,176 KB
testcase_29 AC 133 ms
41,124 KB
testcase_30 AC 145 ms
41,596 KB
testcase_31 AC 133 ms
41,428 KB
testcase_32 AC 134 ms
41,412 KB
testcase_33 AC 147 ms
41,636 KB
testcase_34 AC 134 ms
41,420 KB
testcase_35 AC 133 ms
41,684 KB
testcase_36 AC 145 ms
41,840 KB
testcase_37 AC 143 ms
41,504 KB
testcase_38 AC 146 ms
41,284 KB
testcase_39 AC 137 ms
41,160 KB
testcase_40 AC 145 ms
41,352 KB
testcase_41 AC 143 ms
41,148 KB
testcase_42 AC 140 ms
41,368 KB
testcase_43 AC 140 ms
41,796 KB
testcase_44 AC 142 ms
41,776 KB
testcase_45 AC 146 ms
41,312 KB
testcase_46 AC 135 ms
41,232 KB
testcase_47 AC 149 ms
41,532 KB
testcase_48 AC 139 ms
41,476 KB
testcase_49 AC 137 ms
41,304 KB
testcase_50 AC 143 ms
41,324 KB
testcase_51 AC 141 ms
42,096 KB
testcase_52 AC 146 ms
41,808 KB
testcase_53 AC 141 ms
41,324 KB
testcase_54 AC 123 ms
41,728 KB
testcase_55 AC 138 ms
41,596 KB
testcase_56 AC 138 ms
41,604 KB
testcase_57 AC 133 ms
41,300 KB
testcase_58 AC 144 ms
41,656 KB
testcase_59 AC 148 ms
41,456 KB
testcase_60 AC 140 ms
41,664 KB
testcase_61 AC 148 ms
41,464 KB
testcase_62 AC 132 ms
41,636 KB
testcase_63 AC 135 ms
41,728 KB
testcase_64 AC 138 ms
41,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long gcd = 0;
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextLong();
            if (i == 0) {
                gcd = arr[i];
            } else {
                gcd = getGCD(gcd, arr[i]);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(":");
            }
            sb.append(arr[i] / gcd);
        }
        System.out.println(sb);
    }
    
    static long getGCD(long x, long y) {
        if (x % y == 0) {
            return y;
        } else {
            return getGCD(y, x % y);
        }
    }
}
0