結果
| 問題 |
No.736 約比
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-28 22:01:09 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 189 ms / 2,000 ms |
| コード長 | 774 bytes |
| コンパイル時間 | 2,660 ms |
| コンパイル使用メモリ | 81,408 KB |
| 実行使用メモリ | 55,456 KB |
| 最終ジャッジ日時 | 2024-10-12 06:20:06 |
| 合計ジャッジ時間 | 14,529 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 65 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
new Main().run();
}
final long MOD = (long) (1e9 + 7);
public void run() throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] a = new long[n];
long gcd = a[0];
for (int i = 0; i < n; ++i) {
a[i] = sc.nextLong();
gcd = gcd(a[i], gcd);
}
for (int i = 0; i < n; ++i) {
a[i] /= gcd;
}
for (int i = 0; i < n; ++i) {
System.out.print(a[i] + (i == n - 1 ? "\n" : ":"));
}
}
long gcd(long a, long b) {
if (a > b)
return gcd(b, a);
if (a == 0)
return b;
return gcd(b % a, a);
}
void tr(Object... objects) {
System.out.println(Arrays.deepToString(objects));
}
}