結果

問題 No.736 約比
ユーザー Mcpu3
提出日時 2018-09-29 00:55:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 63,488 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 07:50:37
合計ジャッジ時間 2,077 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 65
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long gcd(long x, long y) {
    long r;
    if (y > x) swap(x, y);
    while (y > 0) {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main() {
    int N;
    long a[100], tmp[100];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        tmp[i] = a[i];
    }
    for (int i = 1; i < N; ++i) tmp[i] = gcd(tmp[i - 1], tmp[i]);
    for (int i = 0; i < N; ++i) {
        cout << a[i] / tmp[N - 1];
        if (i != N - 1) cout << ":";
    }
}
0