結果

問題 No.554 recurrence formula
ユーザー URechaRechaURechaRecha
提出日時 2019-09-06 10:02:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 291 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 86,660 KB
実行使用メモリ 75,720 KB
最終ジャッジ日時 2023-09-05 20:04:48
合計ジャッジ時間 2,936 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,216 KB
testcase_01 AC 77 ms
71,204 KB
testcase_02 AC 77 ms
71,220 KB
testcase_03 AC 76 ms
71,484 KB
testcase_04 AC 78 ms
71,284 KB
testcase_05 AC 76 ms
71,228 KB
testcase_06 AC 76 ms
71,576 KB
testcase_07 AC 75 ms
71,216 KB
testcase_08 AC 76 ms
71,232 KB
testcase_09 AC 78 ms
71,048 KB
testcase_10 AC 77 ms
71,216 KB
testcase_11 AC 80 ms
75,664 KB
testcase_12 AC 80 ms
75,580 KB
testcase_13 AC 79 ms
75,604 KB
testcase_14 AC 79 ms
75,416 KB
testcase_15 AC 80 ms
75,612 KB
testcase_16 AC 81 ms
75,680 KB
testcase_17 AC 80 ms
75,576 KB
testcase_18 AC 79 ms
75,476 KB
testcase_19 AC 81 ms
75,720 KB
testcase_20 AC 81 ms
75,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n= int(input())
    dp=[[2,2],[1,1]]
    div =7+10**9
    for i in range(3,n+1,2):
        dp[1][0]=(i *dp[0][1])%div
        dp[1][1]+=dp[1][0]
        dp[0][0]=((i+1) * dp[1][1])%div
        dp[0][1]+=dp[0][0]
    if n%2 == 0:print(dp[0][0])
    else:print(dp[1][0])
main()
0