結果
| 問題 |
No.339 何人が回答したのか
|
| コンテスト | |
| ユーザー |
明智重蔵
|
| 提出日時 | 2016-10-26 21:12:37 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 1,000 ms |
| コード長 | 1,836 bytes |
| コンパイル時間 | 2,374 ms |
| コンパイル使用メモリ | 108,160 KB |
| 実行使用メモリ | 19,200 KB |
| 最終ジャッジ日時 | 2024-11-24 03:54:34 |
| 合計ジャッジ時間 | 5,761 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
using System.Collections.Generic;
using System.Linq;
//YukiCoder339 何人が回答したのか
//https://yukicoder.me/problems/no/339
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("2");
WillReturn.Add("50");
WillReturn.Add("50");
//2
}
else if (InputPattern == "Input2") {
WillReturn.Add("1");
WillReturn.Add("100");
//1
}
else if (InputPattern == "Input3") {
WillReturn.Add("3");
WillReturn.Add("60");
WillReturn.Add("30");
WillReturn.Add("10");
//10
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int[] AArr = InputList.Skip(1).Select(X => int.Parse(X)).ToArray();
int CurrGCD = AArr[0];
foreach (int EachA in AArr.Skip(1)) {
CurrGCD = DeriveGCD(EachA, CurrGCD);
}
Console.WriteLine(AArr.Sum(X => X / CurrGCD));
}
//ユークリッドの互除法で2数の最大公約数を求める
static private int DeriveGCD(int pVal1, int pVal2)
{
pVal1 = Math.Abs(pVal1);
pVal2 = Math.Abs(pVal2);
int WarareruKazu = Math.Max(pVal1, pVal2);
int WaruKazu = Math.Min(pVal1, pVal2);
while (true) {
int Amari = WarareruKazu % WaruKazu;
if (Amari == 0) return WaruKazu;
WarareruKazu = WaruKazu;
WaruKazu = Amari;
}
}
}
明智重蔵