結果

問題 No.533 Mysterious Stairs
ユーザー mbanmban
提出日時 2017-06-24 07:15:46
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 1,424 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 103,492 KB
実行使用メモリ 51,360 KB
最終ジャッジ日時 2023-07-27 11:12:49
合計ジャッジ時間 5,465 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
18,708 KB
testcase_01 AC 57 ms
22,832 KB
testcase_02 AC 57 ms
20,664 KB
testcase_03 AC 55 ms
20,728 KB
testcase_04 AC 56 ms
20,760 KB
testcase_05 AC 56 ms
20,656 KB
testcase_06 AC 56 ms
20,808 KB
testcase_07 AC 57 ms
20,752 KB
testcase_08 AC 56 ms
20,672 KB
testcase_09 AC 56 ms
20,672 KB
testcase_10 AC 55 ms
22,848 KB
testcase_11 AC 57 ms
18,696 KB
testcase_12 AC 55 ms
18,528 KB
testcase_13 AC 56 ms
20,780 KB
testcase_14 AC 56 ms
22,696 KB
testcase_15 AC 55 ms
20,656 KB
testcase_16 AC 55 ms
20,652 KB
testcase_17 AC 57 ms
20,544 KB
testcase_18 AC 56 ms
20,672 KB
testcase_19 AC 58 ms
20,572 KB
testcase_20 AC 69 ms
25,580 KB
testcase_21 AC 71 ms
26,000 KB
testcase_22 AC 97 ms
32,116 KB
testcase_23 AC 160 ms
50,956 KB
testcase_24 AC 162 ms
51,360 KB
testcase_25 AC 68 ms
23,496 KB
testcase_26 AC 148 ms
44,928 KB
testcase_27 AC 84 ms
32,072 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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N;
    private const int Mod = (int)1e9 + 7;

    public void Solve()
    {
        N = int.Parse(Console.ReadLine());
        var dp = new long[N + 10, 4];
        dp[0, 0] = 1;
        for (int i = 0; i < N; i++)
        {
            if (i == 0)
            {
                dp[i + 1, 1] = dp[i, 0];
                dp[i + 2, 2] = dp[i, 0];
                dp[i + 3, 3] = dp[i, 0];
            }
            else
            {
                if (dp[i, 1] != 0)
                {
                    dp[i + 2, 2] += dp[i, 1];
                    dp[i + 3, 3] += dp[i, 1];
                }
                if (dp[i, 2] != 0)
                {
                    dp[i + 3, 3] += dp[i, 2];
                    dp[i + 1, 1] += dp[i, 2];
                }
                if (dp[i, 3] != 0)
                {
                    dp[i + 1, 1] += dp[i, 3];
                    dp[i + 2, 2] += dp[i, 3];
                }
            }
            dp[i + 1, 1] %= Mod;
            dp[i + 4, 2] %= Mod;
            dp[i + 3, 3] %= Mod;
        }
        Console.WriteLine((dp[N, 1] + dp[N, 2] + dp[N, 3]) % Mod);
    }
}
0