結果

問題 No.736 約比
ユーザー k
提出日時 2020-06-13 08:29:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 3,391 ms
コンパイル使用メモリ 193,664 KB
最終ジャッジ日時 2025-01-11 03:38:25
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 65
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  return gcd(b, a%b);    
}

// override function template of std::gcd
long long gcd(int a, int b) {
  return gcd((long long)a, (long long)b);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;
  vector<long long> a(n);
  REP (i, n) cin >> a[i];

  long long g = 0;
  for (long long x: a)
    g = gcd(g, x);

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