結果

問題 No.978 Fibonacci Convolution Easy
ユーザー AEnAEn
提出日時 2022-05-19 09:42:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 397 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 200,404 KB
最終ジャッジ日時 2023-10-17 17:51:45
合計ジャッジ時間 4,147 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
60,400 KB
testcase_01 WA -
testcase_02 AC 65 ms
89,236 KB
testcase_03 WA -
testcase_04 AC 69 ms
93,276 KB
testcase_05 AC 47 ms
66,224 KB
testcase_06 AC 79 ms
107,708 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 112 ms
169,484 KB
testcase_10 WA -
testcase_11 AC 75 ms
102,028 KB
testcase_12 AC 47 ms
65,400 KB
testcase_13 AC 78 ms
107,700 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 36 ms
53,516 KB
testcase_19 AC 36 ms
53,516 KB
testcase_20 AC 36 ms
53,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, p = map(int, input().split())
a = [0, 1]
mod = 10**9+7
if N < 3:
    res = 0
    for i in range(N):
        for j in range(i+1):
            res += a[i]*a[j]
    print(res)
else:
    ss = 1
    sm = 1
    for i in range(2, N):
        n = p*a[-1]+a[-2]
        n %= mod
        ss += n**2
        ss %= mod
        sm += n
        sm %= mod
        a.append(n)
    print(((sm**2-ss)//2+ss)%mod)
0