結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2024-10-10 23:48:40 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 623 ms / 5,000 ms |
コード長 | 1,957 bytes |
コンパイル時間 | 965 ms |
コンパイル使用メモリ | 111,708 KB |
実行使用メモリ | 42,920 KB |
最終ジャッジ日時 | 2024-10-10 23:48:45 |
合計ジャッジ時間 | 5,157 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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//1回のjumpで2stepする方法しかありません。//1step+1stepという連続した同step数のjumpは行う事が出来ません。}else if (InputPattern == "Input2") {WillReturn.Add("4");//3//(1,2,1),(3,1),(1,3)の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);}}