結果
| 問題 |
No.736 約比
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-10 10:55:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 657 bytes |
| コンパイル時間 | 659 ms |
| コンパイル使用メモリ | 71,648 KB |
| 最終ジャッジ日時 | 2025-01-09 15:38:57 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 65 |
ソースコード
#include <iostream>
#include <numeric>
#include <vector>
template <class T>
T gcd(T n, T m) {
while (m != 0) {
n %= m;
std::swap(n, m);
}
return n;
}
using lint = long long;
void solve() {
int n;
std::cin >> n;
std::vector<lint> xs(n);
for (auto& x : xs) std::cin >> x;
auto g = std::accumulate(xs.begin(), xs.end(), 0LL,
[](lint acc, lint x) { return gcd(acc, x); });
for (int i = 0; i < n; ++i) {
std::cout << xs[i] / g << ":\n"[i == n - 1];
}
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}