結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2017-06-24 08:33:31 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 568 ms / 5,000 ms |
コード長 | 1,739 bytes |
コンパイル時間 | 769 ms |
コンパイル使用メモリ | 114,340 KB |
実行使用メモリ | 45,076 KB |
最終ジャッジ日時 | 2024-10-04 05:14:19 |
合計ジャッジ時間 | 4,650 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
コンパイルメッセージ
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 = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("2"); //1 } else if (InputPattern == "Input2") { WillReturn.Add("4"); //3 } else if (InputPattern == "Input3") { WillReturn.Add("49993"); //407466683 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { const int Hou = 1000000007; List<string> InputList = GetInputList(); int N = int.Parse(InputList[0]); //場合の数[現在位置,前のStep数]なDP表 int[,] DPArr = new int[N + 1, 4]; DPArr[0, 0] = 1; for (int I = 0; I <= N; I++) { for (int J = 0; J <= 3; J++) { if (DPArr[I, J] == 0) continue; //歩数の候補 var HosuuList = new List<int>() { 1, 2, 3 }; HosuuList.Remove(J); foreach (int EachHosuu in HosuuList) { int NewI = I + EachHosuu; if (NewI > N) break; int NewJ = EachHosuu; DPArr[NewI, NewJ] += DPArr[I, J]; DPArr[NewI, NewJ] %= Hou; } } } int Answer = 0; for (int J = 1; J <= 3; J++) { Answer += DPArr[N, J]; Answer %= Hou; } Console.WriteLine(Answer); } }