結果
問題 | No.339 何人が回答したのか |
ユーザー |
|
提出日時 | 2016-03-11 13:14:32 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 25 ms / 1,000 ms |
コード長 | 965 bytes |
コンパイル時間 | 1,158 ms |
コンパイル使用メモリ | 108,668 KB |
実行使用メモリ | 25,804 KB |
最終ジャッジ日時 | 2024-09-25 00:15:44 |
合計ジャッジ時間 | 4,081 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 61 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; namespace No339 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] a = new int[n]; for (int i = 0; i < a.Length; i++) a[i] = int.Parse(Console.ReadLine()); int temp = a[0]; for (int i = 1; i < n; i++) { temp = Gdc(temp, a[i]); } int sum = 0; foreach (int data in a) sum += data / temp; Console.WriteLine(sum); } static int Gdc(int a, int b) { int temp; if (a < b) { temp = a; a = b; b = temp; } do { temp = a % b; a = b; b = temp; } while (b != 0); return a; } } }