結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
30,612 KB
testcase_01 AC 23 ms
25,880 KB
testcase_02 AC 23 ms
25,624 KB
testcase_03 AC 22 ms
23,684 KB
testcase_04 AC 22 ms
23,936 KB
testcase_05 AC 23 ms
25,876 KB
testcase_06 AC 24 ms
23,676 KB
testcase_07 AC 22 ms
23,572 KB
testcase_08 AC 22 ms
21,684 KB
testcase_09 AC 22 ms
23,680 KB
testcase_10 AC 49 ms
23,680 KB
testcase_11 AC 280 ms
24,320 KB
testcase_12 AC 208 ms
24,112 KB
testcase_13 AC 804 ms
25,936 KB
testcase_14 AC 281 ms
24,316 KB
testcase_15 AC 953 ms
26,616 KB
testcase_16 AC 1,210 ms
24,320 KB
testcase_17 AC 566 ms
22,064 KB
testcase_18 AC 478 ms
24,188 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 %= 1000000000 + 7;
        }
        v *= n;
        v %= 1000000000 + 7;

        dict[n] = v;
        return v;
    }

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