結果
| 問題 | No.736 約比 | 
| コンテスト | |
| ユーザー | 👑 | 
| 提出日時 | 2019-03-30 01:03:36 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 674 bytes | 
| コンパイル時間 | 1,276 ms | 
| コンパイル使用メモリ | 64,220 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-07 01:36:58 | 
| 合計ジャッジ時間 | 2,265 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 65 | 
ソースコード
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
long getgcd(long a, long b){
    while(0 < a and 0 < b){
        if(a < b)
            b = b % a;
        else
            a = a % b;
    }
    return std::max(a, b);
}
int main()
{
    long n;
    std::cin >> n;
    std::vector<long> t;
    for(long i = 0; i < n; i++){
        long a;
        std::cin >> a;
        t.push_back(a);
    }
    long gcd = t[0];
    for (long i = 1; i < n; i++){
        gcd = getgcd(gcd, t[i]);        
    }
    for (long i = 0; i < n; i++){
        if(0 < i) {std::cout << ":";}
        t[i] /= gcd;
        std::cout << t[i];
    }
    std::cout << std::endl;
}
            
            
            
        