結果
| 問題 | No.736 約比 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-09-29 00:14:29 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 749 bytes | 
| コンパイル時間 | 2,132 ms | 
| コンパイル使用メモリ | 66,424 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-12 07:45:10 | 
| 合計ジャッジ時間 | 2,396 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 65 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
int main(void) {
    int n;
    vector<ll> a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    const vector<ll> b = a;
    sort(a.begin(), a.end());
    ll cd = gcd(a[0], a[1]);
    for (int j = 1; j < n; ++j) {
        cd = gcd(a[j], cd);
    }
    for (int k = 0; k < n; ++k) {
        if (cd == 1) {
            cout << b[k];
        } else {
            cout << b[k] / cd;
        }
        if (k != n - 1) {
            cout << ":";
        }
    }
    cout << endl;
}
            
            
            
        