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