結果
| 問題 | No.736 約比 | 
| コンテスト | |
| ユーザー |  takeya_okino | 
| 提出日時 | 2019-08-18 22:25:17 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 171 ms / 2,000 ms | 
| コード長 | 593 bytes | 
| コンパイル時間 | 2,080 ms | 
| コンパイル使用メモリ | 77,088 KB | 
| 実行使用メモリ | 54,800 KB | 
| 最終ジャッジ日時 | 2024-10-01 14:34:09 | 
| 合計ジャッジ時間 | 13,285 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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[] A = new long[n];
    A[0] = sc.nextLong();
    long ans = A[0];
    for(int i = 1; i < n; i++) {
      A[i] = sc.nextLong();
      ans = gcd(ans, A[i]);
    }
    for(int i = 0; i < n; i++) {
      if(i < n - 1) {
        System.out.print(A[i] / ans + ":");
      } else {
        System.out.print(A[i] / ans);
      }
    }
  }
  public static long gcd(long a, long b) {
    if(b == 0) return a;
    return gcd(b, (a % b));
  }
}
            
            
            
        