結果

問題 No.533 Mysterious Stairs
ユーザー 明智重蔵明智重蔵
提出日時 2017-06-24 08:33:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 550 ms / 5,000 ms
コード長 1,739 bytes
コンパイル時間 960 ms
コンパイル使用メモリ 116,228 KB
実行使用メモリ 44,952 KB
最終ジャッジ日時 2024-04-14 23:35:28
合計ジャッジ時間 5,022 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
22,064 KB
testcase_01 AC 27 ms
25,744 KB
testcase_02 AC 24 ms
21,816 KB
testcase_03 AC 22 ms
23,832 KB
testcase_04 AC 23 ms
25,916 KB
testcase_05 AC 22 ms
23,836 KB
testcase_06 AC 21 ms
23,828 KB
testcase_07 AC 21 ms
23,812 KB
testcase_08 AC 21 ms
24,112 KB
testcase_09 AC 21 ms
25,880 KB
testcase_10 AC 23 ms
23,600 KB
testcase_11 AC 21 ms
21,812 KB
testcase_12 AC 23 ms
23,708 KB
testcase_13 AC 24 ms
23,968 KB
testcase_14 AC 24 ms
23,728 KB
testcase_15 AC 24 ms
23,724 KB
testcase_16 AC 26 ms
24,112 KB
testcase_17 AC 26 ms
23,964 KB
testcase_18 AC 27 ms
25,616 KB
testcase_19 AC 29 ms
27,824 KB
testcase_20 AC 81 ms
31,124 KB
testcase_21 AC 86 ms
29,076 KB
testcase_22 AC 219 ms
35,356 KB
testcase_23 AC 526 ms
44,952 KB
testcase_24 AC 549 ms
42,908 KB
testcase_25 AC 98 ms
30,992 KB
testcase_26 AC 550 ms
42,768 KB
testcase_27 AC 183 ms
31,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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);
    }
}
0