結果

問題 No.1706 Many Bus Stops (hard)
ユーザー Kiri8128Kiri8128
提出日時 2021-10-08 23:22:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 76,552 KB
最終ジャッジ日時 2023-09-30 13:17:14
合計ジャッジ時間 5,273 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,296 KB
testcase_01 AC 70 ms
71,308 KB
testcase_02 AC 79 ms
76,376 KB
testcase_03 AC 78 ms
76,100 KB
testcase_04 AC 79 ms
76,472 KB
testcase_05 AC 79 ms
76,368 KB
testcase_06 AC 78 ms
76,288 KB
testcase_07 AC 77 ms
76,404 KB
testcase_08 AC 79 ms
76,356 KB
testcase_09 AC 78 ms
76,224 KB
testcase_10 AC 78 ms
76,404 KB
testcase_11 AC 80 ms
76,384 KB
testcase_12 AC 80 ms
76,380 KB
testcase_13 AC 80 ms
76,552 KB
testcase_14 AC 81 ms
76,412 KB
testcase_15 AC 79 ms
76,356 KB
testcase_16 AC 79 ms
76,276 KB
testcase_17 AC 81 ms
76,456 KB
testcase_18 AC 80 ms
76,408 KB
testcase_19 AC 81 ms
76,412 KB
testcase_20 AC 79 ms
76,368 KB
testcase_21 AC 83 ms
76,524 KB
testcase_22 AC 81 ms
76,096 KB
testcase_23 AC 81 ms
76,404 KB
testcase_24 AC 79 ms
76,316 KB
testcase_25 AC 78 ms
76,280 KB
testcase_26 AC 79 ms
76,460 KB
testcase_27 AC 79 ms
76,432 KB
testcase_28 AC 77 ms
76,464 KB
testcase_29 AC 79 ms
76,356 KB
testcase_30 AC 79 ms
76,336 KB
testcase_31 AC 79 ms
76,220 KB
testcase_32 AC 80 ms
76,512 KB
testcase_33 AC 77 ms
76,140 KB
testcase_34 AC 77 ms
76,428 KB
testcase_35 AC 79 ms
76,288 KB
testcase_36 AC 79 ms
76,224 KB
testcase_37 AC 78 ms
76,404 KB
testcase_38 AC 80 ms
76,192 KB
testcase_39 AC 79 ms
76,108 KB
testcase_40 AC 79 ms
76,428 KB
testcase_41 AC 83 ms
76,400 KB
testcase_42 AC 78 ms
76,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mmult(A, B):
    global mod
    n, m, l = len(A), len(B), len(B[0])
    ret = [[0] * l for _ in range(n)]
    for i in range(n):
        for j in range(m):
            for k in range(l):
                ret[i][k] = (ret[i][k] + A[i][j] * B[j][k]) % mod
    return ret
def mpow(A, n):
    if n == 1: return A
    if n == 0: return [[1 if i == j else 0 for j in range(len(A))] for i in range(len(A))]
    return mmult(mpow(A, n - 1), A) if n % 2 else mpow(mmult(A, A), n // 2)

C, N, M = map(int, input().split())
mod = 10 ** 9 + 7
iv = pow(C, mod - 2, mod)
iv1 = iv * (C - 1) % mod
iv2 = iv * (C - 2) % mod
X = [[iv, 0, 0, iv], [0, iv, iv1, iv2], [1, 0, 0, 0], [0, 1, 0, 0]]

print((1 - pow(1 - mpow(X, N)[0][0], M, mod)) % mod)
0