結果

問題 No.736 約比
ユーザー ut0s
提出日時 2019-09-15 08:10:07
言語 C++14
(gcc 8.3.0)
結果
AC  
実行時間 4 ms
コード長 693 Byte
コンパイル時間 1,357 ms
使用メモリ 1,524 KB
最終ジャッジ日時 2019-09-15 08:10:12

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
Rand1_case1.txt AC 3 ms
1,520 KB
Rand1_case2.txt AC 3 ms
1,520 KB
Rand1_case3.txt AC 3 ms
1,520 KB
Rand1_case4.txt AC 4 ms
1,520 KB
Rand1_case5.txt AC 4 ms
1,520 KB
Rand2_case1.txt AC 3 ms
1,512 KB
Rand2_case2.txt AC 3 ms
1,516 KB
Rand2_case3.txt AC 3 ms
1,520 KB
Rand2_case4.txt AC 3 ms
1,524 KB
Rand2_case5.txt AC 4 ms
1,524 KB
Rand3_case1.txt AC 2 ms
1,520 KB
Rand3_case2.txt AC 4 ms
1,520 KB
Rand4_case1.txt AC 4 ms
1,524 KB
Rand4_case2.txt AC 4 ms
1,524 KB
Rand5_case1.txt AC 4 ms
1,524 KB
Rand5_case2.txt AC 4 ms
1,520 KB
Rand6_case1.txt AC 3 ms
1,520 KB
Rand6_case2.txt AC 2 ms
1,520 KB
Rand7_case1.txt AC 2 ms
1,524 KB
Rand7_case2.txt AC 4 ms
1,520 KB
Rand8_case1.txt AC 3 ms
1,524 KB
Rand8_case2.txt AC 4 ms
1,520 KB
Rand9_case1.txt AC 2 ms
1,516 KB
Rand9_case2.txt AC 3 ms
1,520 KB
Rand9_case3.txt AC 2 ms
1,524 KB
Rand9_case4.txt AC 3 ms
1,516 KB
Rand9_case5.txt AC 3 ms
1,516 KB
Rand9_case6.txt AC 3 ms
1,520 KB
Rand9_case7.txt AC 3 ms
1,520 KB
Rand9_case8.txt AC 3 ms
1,520 KB
Rand9_case9.txt AC 3 ms
1,524 KB
Rand9_case10.txt AC 3 ms
1,520 KB
Rand9_case11.txt AC 2 ms
1,520 KB
Rand9_case12.txt AC 4 ms
1,520 KB
Rand9_case13.txt AC 3 ms
1,520 KB
Rand9_case14.txt AC 4 ms
1,516 KB
Rand9_case15.txt AC 3 ms
1,520 KB
Rand9_case16.txt AC 3 ms
1,520 KB
Rand9_case17.txt AC 3 ms
1,520 KB
Rand9_case18.txt AC 3 ms
1,516 KB
Rand9_case19.txt AC 3 ms
1,520 KB
Rand9_case20.txt AC 3 ms
1,520 KB
RandA_case1.txt AC 3 ms
1,524 KB
RandA_case2.txt AC 3 ms
1,520 KB
RandA_case3.txt AC 3 ms
1,524 KB
RandA_case4.txt AC 3 ms
1,520 KB
RandA_case5.txt AC 3 ms
1,516 KB
RandA_case6.txt AC 3 ms
1,520 KB
RandA_case7.txt AC 3 ms
1,524 KB
RandA_case8.txt AC 3 ms
1,516 KB
RandA_case9.txt AC 3 ms
1,516 KB
RandA_case10.txt AC 2 ms
1,520 KB
RandA_case11.txt AC 3 ms
1,520 KB
RandA_case12.txt AC 3 ms
1,520 KB
RandA_case13.txt AC 4 ms
1,520 KB
RandA_case14.txt AC 3 ms
1,520 KB
RandA_case15.txt AC 3 ms
1,520 KB
RandA_case16.txt AC 4 ms
1,520 KB
RandA_case17.txt AC 3 ms
1,524 KB
RandA_case18.txt AC 4 ms
1,520 KB
RandA_case19.txt AC 3 ms
1,524 KB
RandA_case20.txt AC 4 ms
1,524 KB
Sample_1.txt AC 3 ms
1,520 KB
Sample_2.txt AC 3 ms
1,520 KB
Sample_3.txt AC 3 ms
1,516 KB
テストケース一括ダウンロード

ソースコード

diff #
/**
  @file 736.cpp
  @title  No.736 約比 - yukicoder
  @url https://yukicoder.me/problems/no/736
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

template <class T>
T gcd(T a, T b) {
  if (b == 0)
    return a;

  return gcd(b, a % b);
}

int main() {
  int N;
  cin >> N;
  vector<LL> a(N, 0);
  LL div;
  REP(i, N) {
    cin >> a[i];
    if (i > 0) {
      div = gcd(a[i], div);
    } else {
      div = a[0];
    }
  }

  cout << a[0] / div << ":";
  for (int i = 1; i < N - 1; i++) {
    cout << a[i] / div << ":";
  }
  cout << a[N - 1] / div << "\n";

  return 0;
}
0