結果

問題 No.736 約比
ユーザー face4face4
提出日時 2018-09-28 21:29:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 69,336 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-12 05:38:29
合計ジャッジ時間 1,947 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 65
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
    return b == 0 ? a : gcd(b, a%b);
}

int main(){
    int n;
    cin >> n;

    vector<ll> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];

    ll g = v[0];
    for(int i = 1; i < n; i++)  g = gcd(g, v[i]);

    for(int i = 0; i < n; i++)  v[i] /= g;

    cout << v[0];
    for(int i = 1; i < n; i++){
        cout << ":" << v[i];
    }
    cout << endl;
    
    return 0;
}
0