結果

問題 No.554 recurrence formula
ユーザー ebicochinealebicochineal
提出日時 2017-08-11 23:33:12
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 745 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 104,272 KB
実行使用メモリ 44,272 KB
最終ジャッジ日時 2023-08-02 23:52:22
合計ジャッジ時間 9,661 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
44,272 KB
testcase_01 AC 55 ms
21,460 KB
testcase_02 AC 56 ms
25,680 KB
testcase_03 AC 55 ms
21,468 KB
testcase_04 AC 56 ms
23,436 KB
testcase_05 AC 55 ms
23,516 KB
testcase_06 AC 54 ms
21,412 KB
testcase_07 AC 53 ms
23,460 KB
testcase_08 AC 54 ms
21,460 KB
testcase_09 AC 55 ms
21,540 KB
testcase_10 AC 70 ms
21,540 KB
testcase_11 AC 187 ms
19,496 KB
testcase_12 AC 152 ms
21,548 KB
testcase_13 AC 470 ms
21,472 KB
testcase_14 AC 189 ms
23,652 KB
testcase_15 AC 549 ms
23,580 KB
testcase_16 AC 652 ms
23,500 KB
testcase_17 AC 341 ms
21,448 KB
testcase_18 AC 289 ms
21,456 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.Linq;
using System.Text;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;

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