結果

問題 No.554 recurrence formula
ユーザー mlihua09mlihua09
提出日時 2020-09-15 02:11:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 260 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 76,052 KB
最終ジャッジ日時 2023-09-04 01:25:54
合計ジャッジ時間 3,008 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,052 KB
testcase_01 AC 71 ms
71,240 KB
testcase_02 AC 71 ms
71,352 KB
testcase_03 AC 70 ms
71,208 KB
testcase_04 AC 71 ms
71,200 KB
testcase_05 AC 70 ms
71,332 KB
testcase_06 AC 70 ms
71,228 KB
testcase_07 AC 71 ms
71,304 KB
testcase_08 AC 69 ms
71,092 KB
testcase_09 AC 71 ms
71,424 KB
testcase_10 AC 73 ms
71,424 KB
testcase_11 AC 73 ms
75,772 KB
testcase_12 AC 74 ms
75,796 KB
testcase_13 AC 75 ms
75,900 KB
testcase_14 AC 74 ms
75,940 KB
testcase_15 AC 75 ms
75,852 KB
testcase_16 AC 73 ms
75,964 KB
testcase_17 AC 75 ms
75,716 KB
testcase_18 AC 75 ms
75,832 KB
testcase_19 AC 77 ms
76,052 KB
testcase_20 AC 77 ms
75,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

mod = 10 ** 9 + 7

x = 1
y = 0
if n == 1:
    print(1)
    exit()
for i in range(2, n - 1, 2):
    y += i * x
    x += (i + 1) * y
    x %= mod
    y %= mod

if n % 2:
    y += (n - 1) * x
    print(n * y % mod)

else:
    print(n * x % mod)
0