結果

問題 No.554 recurrence formula
ユーザー RisenRisen
提出日時 2017-08-11 22:58:39
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 643 bytes
コンパイル時間 863 ms
コンパイル使用メモリ 105,088 KB
実行使用メモリ 30,236 KB
最終ジャッジ日時 2024-04-20 23:17:23
合計ジャッジ時間 9,761 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
24,864 KB
testcase_01 AC 21 ms
17,920 KB
testcase_02 AC 22 ms
17,792 KB
testcase_03 AC 23 ms
17,536 KB
testcase_04 AC 22 ms
17,664 KB
testcase_05 AC 21 ms
17,792 KB
testcase_06 AC 21 ms
17,536 KB
testcase_07 AC 22 ms
17,664 KB
testcase_08 AC 24 ms
17,664 KB
testcase_09 AC 22 ms
17,664 KB
testcase_10 AC 49 ms
17,664 KB
testcase_11 AC 284 ms
18,176 KB
testcase_12 AC 220 ms
17,792 KB
testcase_13 AC 845 ms
18,304 KB
testcase_14 AC 284 ms
18,176 KB
testcase_15 AC 993 ms
18,688 KB
testcase_16 AC 1,195 ms
18,944 KB
testcase_17 AC 597 ms
18,432 KB
testcase_18 AC 502 ms
17,920 KB
testcase_19 TLE -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Linq;

class Solution
{
    static Dictionary<int, long> dict = new Dictionary<int, long>() { { 1, 1 } };

    static long F(int n)
    {
        if (dict.ContainsKey(n))
        {
            return dict[n];
        }

        long v = 0;
        for (int i = n % 2 + 1; i <= n - 1; i += 2)
        {
            v += F(i);
            v %= 1_000_000_000 + 7;
        }
        v *= n;
        v %= 1_000_000_000 + 7;

        dict[n] = v;
        return v;
    }

    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        Console.WriteLine(F(n));
    }
}
0