結果

問題 No.736 約比
ユーザー Mcpu3
提出日時 2018-09-29 00:50:57
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 866 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 75,376 KB
実行使用メモリ 56,092 KB
最終ジャッジ日時 2024-10-12 07:49:36
合計ジャッジ時間 12,313 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 RE * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static long gcd(long x, long y) {
        long r;
        if (y > x) {
            r = x;
            x = y;
            y = r;
        }
        while (y > 0) {
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long a[] = new long[N], tmp[] = new long[N];
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
            tmp[i] = a[i];
        }
        sc.close();
        for (int i = 1; i < N; ++i) tmp[i] = gcd(tmp[i - 1], tmp[i]);
        for (int i = 0; i < N; ++i) {
            System.out.print(a[i] / tmp[N - 1]);
            if (i != N - 1) System.out.print(":");
        }
    }
}
0