結果

問題 No.339 何人が回答したのか
ユーザー femtofemto
提出日時 2016-08-20 15:17:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 525 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 76,696 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 21:34:35
合計ジャッジ時間 2,705 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int A[100];

int gcd(int a, int b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	for(int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int g = A[0];
	for(int i = 1; i < N; i++) {
		g = gcd(g, A[i]);
	}

	int ans = 0;
	for(int i = 0; i < N; i++) {
		ans += A[i] / g;
	}
	cout << ans << endl;
}
0