結果
問題 |
No.44 DPなすごろく
|
ユーザー |
![]() |
提出日時 | 2015-07-21 19:30:54 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 20 ms / 5,000 ms |
コード長 | 1,608 bytes |
コンパイル時間 | 850 ms |
コンパイル使用メモリ | 105,088 KB |
実行使用メモリ | 17,664 KB |
最終ジャッジ日時 | 2024-07-08 11:34:02 |
合計ジャッジ時間 | 2,589 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
コンパイルメッセージ
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; class Program { static string InputPattern = "Input5"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("2"); } else if (InputPattern == "Input2") { WillReturn.Add("3"); } else if (InputPattern == "Input3") { WillReturn.Add("5"); } else if (InputPattern == "Input4") { WillReturn.Add("50"); } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); int N = int.Parse(InputList[0]); //1マスなら1通り //2マスなら2通り //3なら最初に1マス進めば、残り2マスでの場合の数 // 最初に2マス進めば、残り1マスでの場合の数 //4なら最初に1マス進めば、残り3マスでの場合の数 // 最初に2マス進めば、残り2マスでの場合の数 //よって、フィボナッチ数列の漸化式となる 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]); } }