結果

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

ソースコード

diff #

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

template <typename T>
T gcd(T a, T b)
{
	while (b)
	{
		T tmp = b;
		b = a % b;
		a = tmp;
	}
	return a;
}

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	int64_t g = as[0];
	for (auto &a : as)
	{
		g = gcd(g, a);
	}
	for (int i = 0; i < n; i++)
	{
		if (i)
		{
			cout << ':';
		}
		cout << as[i] / g;
	}
	cout << endl;
	return 0;
}
0