結果

問題 No.554 recurrence formula
ユーザー ああいいああいい
提出日時 2022-03-08 14:22:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 268 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 76,776 KB
最終ジャッジ日時 2023-09-30 20:15:28
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,372 KB
testcase_01 AC 70 ms
71,380 KB
testcase_02 AC 70 ms
71,228 KB
testcase_03 AC 68 ms
71,192 KB
testcase_04 AC 68 ms
71,116 KB
testcase_05 AC 70 ms
71,156 KB
testcase_06 AC 68 ms
71,252 KB
testcase_07 AC 69 ms
71,104 KB
testcase_08 AC 70 ms
71,376 KB
testcase_09 AC 70 ms
71,308 KB
testcase_10 AC 75 ms
76,036 KB
testcase_11 AC 74 ms
75,996 KB
testcase_12 AC 75 ms
76,080 KB
testcase_13 AC 74 ms
76,028 KB
testcase_14 AC 72 ms
75,852 KB
testcase_15 AC 74 ms
76,084 KB
testcase_16 AC 75 ms
76,008 KB
testcase_17 AC 74 ms
75,860 KB
testcase_18 AC 74 ms
76,048 KB
testcase_19 AC 74 ms
76,756 KB
testcase_20 AC 76 ms
76,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
P = 10 ** 9 + 7
a = [0] * (n+1)
a[1] = 1
odd = 1
even = 0
for i in range(2,n+1):
    if i % 2 == 0:
        a[i] = i * odd % P
        even = (even + a[i]) % P
    else:
        a[i] = i * even % P
        odd = (odd + a[i]) % P
print(a[-1])
        
0