結果
| 問題 |
No.736 約比
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2019-12-07 13:45:30 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 143 ms / 2,000 ms |
| コード長 | 797 bytes |
| コンパイル時間 | 2,022 ms |
| コンパイル使用メモリ | 74,632 KB |
| 実行使用メモリ | 41,936 KB |
| 最終ジャッジ日時 | 2024-12-25 15:57:13 |
| 合計ジャッジ時間 | 12,405 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 65 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] arr = new long[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextLong();
}
long same = arr[0];
for (int i = 1; i < n; i++) {
same = gcd(same, arr[i]);
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
if (i != 0) {
sb.append(":");
}
sb.append(arr[i] / same);
}
System.out.println(sb);
}
static long gcd(long a, long b) {
if (a % b == 0) {
return b;
} else {
return gcd(b, a % b);
}
}
}
htensai