結果
問題 |
No.339 何人が回答したのか
|
ユーザー |
![]() |
提出日時 | 2016-02-16 03:34:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 406 bytes |
コンパイル時間 | 1,343 ms |
コンパイル使用メモリ | 163,564 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 07:15:35 |
合計ジャッジ時間 | 2,763 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 61 |
ソースコード
#include <bits/stdc++.h> using namespace std; int gcd(int x,int y){ while(x != y){ if(x > y) x -= y; else y -= x; } return x; } 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; }