結果
| 問題 |
No.339 何人が回答したのか
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-01-29 23:25:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 774 bytes |
| コンパイル時間 | 692 ms |
| コンパイル使用メモリ | 72,476 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-21 18:43:22 |
| 合計ジャッジ時間 | 2,258 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 61 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cstring>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int a[100];
int g = INF;
int gcd(int a, int b){
if(b == 0) return a;
return gcd(b, a % b);
}
int main(){
int n;
cin >> n;
rep(i, n) cin >> a[i];
if(n == 1){
puts("1");
return 0;
}
rep(i, n - 1){
for(int j = i + 1;j < n; j++){
if(i != j){
g = min(g, gcd(a[i], a[j]));
}
}
}
int ans = 0;
rep(i, n) ans += a[i] / g;
cout << ans << endl;
return 0;
}