結果

問題 No.554 recurrence formula
ユーザー ebicochinealebicochineal
提出日時 2017-08-11 23:09:51
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 969 ms
コンパイル使用メモリ 104,320 KB
実行使用メモリ 22,912 KB
最終ジャッジ日時 2024-04-20 23:26:22
合計ジャッジ時間 9,646 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
22,912 KB
testcase_01 AC 25 ms
17,408 KB
testcase_02 AC 26 ms
17,792 KB
testcase_03 AC 26 ms
17,408 KB
testcase_04 AC 26 ms
17,792 KB
testcase_05 AC 25 ms
17,664 KB
testcase_06 AC 25 ms
17,664 KB
testcase_07 AC 26 ms
17,920 KB
testcase_08 AC 26 ms
17,408 KB
testcase_09 AC 26 ms
17,920 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
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.Linq;
using System.Text;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;

public class Program {
    static int MOD = 1000000007;
    static Dictionary<int, int> memo = new Dictionary<int, int>() { {1, 1} };
    static int f (int n) {
        if (memo.ContainsKey(n)) { return memo[n]; }
        int s = 0;
        for (int i = 1; i < n; ++i) {
            if (n % 2 == 0 && i % 2 == 1) {
                s += f(i);
                s %= MOD;
            } else if (n % 2 == 1 && i % 2 == 0) {
                s += f(i);
                s %= MOD;
            }
        }
        memo.Add(n, (s * n) % MOD);
        return memo[n];
    }
    
    static void Main (string[] args) {
        int N = int.Parse(Console.ReadLine());
        Console.WriteLine(f(N));
    }
}
0