結果

問題 No.554 recurrence formula
ユーザー nannanynannany
提出日時 2017-08-12 00:05:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 368 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 818,048 KB
最終ジャッジ日時 2024-04-21 00:04:50
合計ジャッジ時間 3,433 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,752 KB
testcase_01 AC 26 ms
10,624 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 25 ms
10,624 KB
testcase_04 AC 26 ms
10,752 KB
testcase_05 AC 25 ms
10,752 KB
testcase_06 AC 24 ms
10,752 KB
testcase_07 AC 25 ms
10,752 KB
testcase_08 AC 25 ms
10,752 KB
testcase_09 AC 26 ms
10,752 KB
testcase_10 AC 28 ms
11,776 KB
testcase_11 AC 44 ms
25,344 KB
testcase_12 AC 38 ms
20,992 KB
testcase_13 AC 84 ms
60,800 KB
testcase_14 AC 44 ms
25,472 KB
testcase_15 AC 96 ms
71,040 KB
testcase_16 AC 112 ms
84,480 KB
testcase_17 AC 67 ms
44,416 KB
testcase_18 AC 63 ms
37,632 KB
testcase_19 MLE -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

if __name__ == '__main__':
    N = int(input())
    memo = [-1 for i in range(N + 1)]
    memo[1] = 1

    sum_odd = 1
    sum_even = 0
    for i in range(2, N + 1):
        if i % 2 == 0:
            memo[i] = sum_odd * i
            sum_even += memo[i]
        else:
            memo[i] = sum_even * i
            sum_odd += memo[i]

    print(memo[N] % 1000000007)
0