結果
問題 |
No.339 何人が回答したのか
|
ユーザー |
![]() |
提出日時 | 2016-02-16 03:32:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 406 bytes |
コンパイル時間 | 1,499 ms |
コンパイル使用メモリ | 163,472 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 07:15:24 |
合計ジャッジ時間 | 2,940 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 61 |
ソースコード
#include <bits/stdc++.h> using namespace std; int gcd(int y,int z){ while(y != z){ if(y > z) y -= z; else z -= y; } return y; } int main(){ long long n; cin >> n; vector<long long> a(n); for(auto &x:a) cin >> x; sort(a.begin(),a.end()); int ans = 0, g = a[0]; for(int i = 1; i < n; i++) g = min(g,gcd(g,a[i])); for(int i = 0; i < n; i++) ans += a[i] / g; cout << ans << endl; return 0; }