結果

問題 No.533 Mysterious Stairs
ユーザー 14番14番
提出日時 2017-06-23 23:13:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,418 ms / 5,000 ms
コード長 1,699 bytes
コンパイル時間 993 ms
コンパイル使用メモリ 112,392 KB
実行使用メモリ 192,464 KB
最終ジャッジ日時 2024-04-15 01:05:19
合計ジャッジ時間 7,678 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,936 KB
testcase_01 AC 26 ms
24,052 KB
testcase_02 AC 26 ms
24,188 KB
testcase_03 AC 26 ms
23,940 KB
testcase_04 AC 26 ms
24,056 KB
testcase_05 AC 27 ms
21,940 KB
testcase_06 AC 26 ms
24,052 KB
testcase_07 AC 26 ms
24,200 KB
testcase_08 AC 27 ms
23,924 KB
testcase_09 AC 27 ms
23,812 KB
testcase_10 AC 27 ms
23,980 KB
testcase_11 AC 28 ms
24,056 KB
testcase_12 AC 29 ms
25,888 KB
testcase_13 AC 29 ms
23,972 KB
testcase_14 AC 29 ms
24,020 KB
testcase_15 AC 29 ms
23,896 KB
testcase_16 AC 31 ms
23,900 KB
testcase_17 AC 36 ms
25,076 KB
testcase_18 AC 39 ms
24,944 KB
testcase_19 AC 43 ms
27,060 KB
testcase_20 AC 183 ms
49,696 KB
testcase_21 AC 200 ms
50,968 KB
testcase_22 AC 576 ms
99,484 KB
testcase_23 AC 1,418 ms
185,860 KB
testcase_24 AC 1,379 ms
192,464 KB
testcase_25 AC 185 ms
48,148 KB
testcase_26 AC 1,216 ms
176,064 KB
testcase_27 AC 373 ms
68,252 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.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int stepCount = int.Parse(Reader.ReadLine());
        for (int i = 1; i <= stepCount; i++) {
            GetAns(0, i);
        }
        long ans = GetAns(0, stepCount);
        Console.WriteLine(ans);

    
    }

    private long Mod = 1000000000 + 7;

    private Dictionary<int, Dictionary<int, long>> dic = new Dictionary<int, Dictionary<int, long>>();
    private long GetAns(int prevStep, int remain) {
        if(remain == 0) {
            return 1;
        }
        if(remain < 0) {
            return 0;
        }
        if(!dic.ContainsKey(prevStep)) {
            dic.Add(prevStep, new Dictionary<int, long>());
        }
        if(dic[prevStep].ContainsKey(remain)) {
            return dic[prevStep][remain];
        }
        long ans = 0;
        for (int i = 1; i <= 3; i++) {
            if(i==prevStep) {
                continue;
            }
            ans += GetAns(i, remain - i);
            ans = ans % Mod;
        }
        dic[prevStep][remain] = ans;
        return ans;
    }






    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



49993







";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}
0