using System; using System.Collections.Generic; class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("2"); //2 //2に行く方法は「1・1」と「2」の2パターンです。 } else if (InputPattern == "Input2") { WillReturn.Add("3"); //3 //3に行く方法は「1・1・1」と「2・1」と「1・2」の3パターンです。 //「2・1」と「1・2」は区別するのでご注意ください。 } else if (InputPattern == "Input3") { WillReturn.Add("5"); //8 //「1・1・1・1・1」 //「2・1・1・1」 //「1・2・1・1」 //「1・1・2・1」 //「1・1・1・2」 //「1・2・2」 //「2・1・2」 //「2・2・1」 //の8通り } else if (InputPattern == "Input4") { WillReturn.Add("50"); //20365011074 //答えは 2の32乗 を超えるのでintでは収まりません。 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); int N = int.Parse(InputList[0]); long[] PatternCntArr = new long[N + 1]; int UB = PatternCntArr.GetUpperBound(0); PatternCntArr[1] = 1; PatternCntArr[2] = 2; for (int I = 3; I <= UB; I++) { PatternCntArr[I] = PatternCntArr[I - 1] + PatternCntArr[I - 2]; } Console.WriteLine(PatternCntArr[UB]); } }