結果

問題 No.339 何人が回答したのか
ユーザー 👑 CleyL
提出日時 2020-01-22 19:46:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 438 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 68,992 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-08 13:28:17
合計ジャッジ時間 2,195 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int gcd(int a,int b){
    if(a%b)return gcd(b,a%b);
    else return b;
}
int main(){
    int n;cin>>n;
    vector<int> a(n);
    int nw;
    for(int i = 0; n > i; i++){
        cin>>a[i];
        if(!i)nw = a[i];
        else{
            nw = gcd(nw,a[i]);
        }
    }
    int ans = 0;
    for(int i = 0; n > i; i++){
        ans += a[i]/nw;
    }
    cout << ans << endl;
}
0