結果

問題 No.1500 Super Knight
ユーザー convexineqconvexineq
提出日時 2021-05-07 21:29:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 86,788 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2023-10-13 12:25:33
合計ジャッジ時間 5,218 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,388 KB
testcase_01 AC 76 ms
75,536 KB
testcase_02 AC 77 ms
75,568 KB
testcase_03 AC 77 ms
75,464 KB
testcase_04 AC 76 ms
75,516 KB
testcase_05 AC 77 ms
75,520 KB
testcase_06 AC 77 ms
75,556 KB
testcase_07 AC 76 ms
75,324 KB
testcase_08 AC 76 ms
75,636 KB
testcase_09 AC 76 ms
75,396 KB
testcase_10 AC 76 ms
75,552 KB
testcase_11 AC 76 ms
75,636 KB
testcase_12 AC 76 ms
75,520 KB
testcase_13 AC 78 ms
75,376 KB
testcase_14 AC 76 ms
75,588 KB
testcase_15 AC 75 ms
75,524 KB
testcase_16 AC 71 ms
71,148 KB
testcase_17 AC 78 ms
76,108 KB
testcase_18 AC 78 ms
76,004 KB
testcase_19 AC 77 ms
75,324 KB
testcase_20 AC 73 ms
71,204 KB
testcase_21 AC 76 ms
75,328 KB
testcase_22 AC 77 ms
75,604 KB
testcase_23 AC 77 ms
75,528 KB
testcase_24 AC 75 ms
75,380 KB
testcase_25 AC 78 ms
76,160 KB
testcase_26 AC 72 ms
71,048 KB
testcase_27 AC 76 ms
75,592 KB
testcase_28 AC 71 ms
71,316 KB
testcase_29 AC 75 ms
75,632 KB
testcase_30 AC 77 ms
75,324 KB
testcase_31 AC 78 ms
75,548 KB
testcase_32 AC 75 ms
75,536 KB
testcase_33 AC 76 ms
75,400 KB
testcase_34 AC 77 ms
75,744 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 = int(input())
MOD = 10**9+7
print(fps_nth_term([1, 9, 32, 12, 999999971, 16], [1, 1000000004, 3, 1000000006, 0, 0, 0],n))
0