結果

問題 No.554 recurrence formula
ユーザー はむ吉🐹はむ吉🐹
提出日時 2017-08-13 17:19:37
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 399 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 10,544 KB
実行使用メモリ 8,004 KB
最終ジャッジ日時 2023-08-03 12:27:57
合計ジャッジ時間 1,514 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,816 KB
testcase_01 AC 16 ms
7,856 KB
testcase_02 AC 17 ms
7,816 KB
testcase_03 AC 16 ms
7,884 KB
testcase_04 AC 17 ms
7,796 KB
testcase_05 AC 17 ms
7,812 KB
testcase_06 AC 17 ms
7,864 KB
testcase_07 AC 16 ms
7,884 KB
testcase_08 AC 16 ms
7,864 KB
testcase_09 AC 15 ms
7,832 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 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

P = 10 ** 9 + 7


def compute(n, mod=P):
    res = 1
    odd_sum = res
    even_sum = 0
    for i in range(2, n + 1):
        if i % 2 == 0:
            res = odd_sum * i
            even_sum += res
        else:
            res = even_sum * i
            odd_sum += res
        odd_sum %= mod
        even_sum %= mod
    return res


def main():
    n = int(input())
    print(compute(n))


main()
0