結果
問題 | No.736 約比 |
ユーザー |
|
提出日時 | 2019-09-15 08:10:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 1,675 ms |
コンパイル使用メモリ | 168,180 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 22:38:55 |
合計ジャッジ時間 | 3,014 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 65 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:36:18: warning: 'div' may be used uninitialized [-Wmaybe-uninitialized] 36 | cout << a[0] / div << ":"; | ^~~ main.cpp:26:6: note: 'div' was declared here 26 | LL div; | ^~~
ソースコード
/**@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;}