結果

問題 No.736 約比
ユーザー YamaKasa
提出日時 2018-09-28 21:35:55
言語 Java
(openjdk 23)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 702 bytes
コンパイル時間 2,575 ms
コンパイル使用メモリ 79,560 KB
実行使用メモリ 42,124 KB
最終ジャッジ日時 2024-10-12 05:42:13
合計ジャッジ時間 14,702 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 65
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long[]a = new long[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextLong();
		}
		scan.close();
		long g = gcd(a[0], a[1]);
		for(int i = 2; i < N; i++) {
			g = gcd(g, a[i]);
		}
		long[]b = new long[N];
		for(int i = 0; i < N; i++) {
			b[i] = a[i] / g;
		}
		for(int i = 0; i < N; i++) {
			long t = a[i] / g;
			if(i == N - 1) {
				System.out.println(t);
			}else {
				System.out.print(t + ":");
			}
		}
	}
	static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}
0