結果

問題 No.444 旨味の相乗効果
ユーザー convexineqconvexineq
提出日時 2021-02-05 08:01:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,500 ms
コード長 635 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 77,196 KB
最終ジャッジ日時 2023-09-14 13:21:51
合計ジャッジ時間 4,027 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,104 KB
testcase_01 AC 72 ms
71,308 KB
testcase_02 AC 73 ms
71,128 KB
testcase_03 AC 71 ms
71,104 KB
testcase_04 AC 102 ms
76,964 KB
testcase_05 AC 72 ms
71,304 KB
testcase_06 AC 72 ms
71,260 KB
testcase_07 AC 77 ms
76,012 KB
testcase_08 AC 78 ms
76,240 KB
testcase_09 AC 76 ms
76,188 KB
testcase_10 AC 74 ms
76,220 KB
testcase_11 AC 74 ms
75,840 KB
testcase_12 AC 85 ms
76,168 KB
testcase_13 AC 84 ms
76,060 KB
testcase_14 AC 78 ms
76,168 KB
testcase_15 AC 71 ms
71,164 KB
testcase_16 AC 100 ms
77,168 KB
testcase_17 AC 72 ms
71,168 KB
testcase_18 AC 81 ms
76,264 KB
testcase_19 AC 83 ms
76,180 KB
testcase_20 AC 99 ms
77,196 KB
testcase_21 AC 72 ms
71,264 KB
testcase_22 AC 74 ms
71,104 KB
testcase_23 AC 74 ms
71,356 KB
testcase_24 AC 80 ms
76,060 KB
testcase_25 AC 72 ms
71,332 KB
testcase_26 AC 71 ms
71,240 KB
testcase_27 AC 79 ms
76,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def polymul(f,g):
    lf = len(f)
    lg = len(g)
    res = [0]*(lf+lg-1)
    for i in range(lf):
        for j in range(lg):
            res[i+j] += f[i]*g[j]
            res[i+j] %= MOD
    return res

def fps_nth_term(f,g,N):
    assert g[0] != 0
    while N:
        h = g[:]
        for i in range(1,len(g),2):
            h[i] = -h[i]
        f = polymul(f,h)[N%2:N+1:2]
        g = polymul(g,h)[:N+1:2]
        N //= 2
    return f[0]*pow(g[0],MOD-2,MOD)%MOD

n,c,*a = map(int,open(0).read().split())
MOD = 10**9+7
r = [1]
x = 0
for ai in a:
    r = polymul(r,[1,-ai])
    x -= pow(ai,c,MOD)
print((x+fps_nth_term([1],r,c))%MOD)
0