AtCoderのABC
次のABCの問題へ
前のABCの問題へ
ABC081-B Shift only
C#のソース
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3");
WillReturn.Add("8 12 40");
//2
}
else if (InputPattern == "Input2") {
WillReturn.Add("4");
WillReturn.Add("5 6 8 10");
//0
}
else if (InputPattern == "Input3") {
WillReturn.Add("6");
WillReturn.Add("382253568 723152896 37802240 379425024 404894720 471526144");
//8
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
int Answer = 0;
while (true) {
for (int I = 0; I <= AArr.GetUpperBound(0); I++) {
if (AArr[I] % 2 == 0) {
AArr[I] /= 2;
}
else {
Console.WriteLine(Answer);
return;
}
}
Answer++;
}
}
}
解説
ナイーブに解いてます。