結果

問題 No.1706 Many Bus Stops (hard)
ユーザー brthyyjpbrthyyjp
提出日時 2021-10-13 09:49:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 775 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 61,972 KB
最終ジャッジ日時 2023-10-17 19:02:47
合計ジャッジ時間 4,812 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,408 KB
testcase_01 AC 38 ms
53,408 KB
testcase_02 AC 46 ms
61,964 KB
testcase_03 AC 46 ms
61,972 KB
testcase_04 AC 46 ms
61,972 KB
testcase_05 AC 45 ms
61,972 KB
testcase_06 AC 46 ms
61,972 KB
testcase_07 AC 46 ms
61,972 KB
testcase_08 AC 45 ms
61,972 KB
testcase_09 AC 47 ms
61,972 KB
testcase_10 AC 45 ms
61,972 KB
testcase_11 AC 46 ms
61,972 KB
testcase_12 AC 46 ms
61,972 KB
testcase_13 AC 47 ms
61,972 KB
testcase_14 AC 46 ms
61,972 KB
testcase_15 AC 46 ms
61,972 KB
testcase_16 AC 47 ms
61,972 KB
testcase_17 AC 46 ms
61,972 KB
testcase_18 AC 46 ms
61,972 KB
testcase_19 AC 46 ms
61,972 KB
testcase_20 AC 46 ms
61,972 KB
testcase_21 AC 45 ms
61,972 KB
testcase_22 AC 46 ms
61,972 KB
testcase_23 AC 46 ms
61,972 KB
testcase_24 AC 45 ms
61,972 KB
testcase_25 AC 46 ms
61,972 KB
testcase_26 AC 46 ms
61,972 KB
testcase_27 AC 46 ms
61,972 KB
testcase_28 AC 46 ms
61,972 KB
testcase_29 AC 46 ms
61,972 KB
testcase_30 AC 45 ms
61,972 KB
testcase_31 AC 46 ms
61,972 KB
testcase_32 AC 46 ms
61,972 KB
testcase_33 AC 47 ms
61,972 KB
testcase_34 AC 46 ms
61,972 KB
testcase_35 AC 46 ms
61,972 KB
testcase_36 AC 47 ms
61,972 KB
testcase_37 AC 46 ms
61,972 KB
testcase_38 AC 46 ms
61,972 KB
testcase_39 AC 46 ms
61,972 KB
testcase_40 AC 46 ms
61,972 KB
testcase_41 AC 46 ms
61,972 KB
testcase_42 AC 45 ms
61,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# A*B
def mat_mul(A, B, mod):
    C = [[0]*len(B[0]) for i in range(len(A))]
    for i in range(len(A)):
        for k in range(len(B)):
            for j in range(len(B[0])):
                C[i][j] = (C[i][j] + A[i][k]*B[k][j])%mod
    return C

#A**n
def mat_pow(A, n, mod):
    B = [[0]*len(A) for i in range(len(A))]
    for i in range(len(A)):
        B[i][i] = 1
    while n > 0:
        if n & 1 == 1:
            B = mat_mul(A, B, mod)
        A = mat_mul(A, A, mod)
        n = n>>1
    return B

c, n, m = map(int, input().split())

mod = 10**9+7
p = pow(c, mod-2, mod)
A = [[p,0,0,p],[0,p,1-p,1-2*p],[1,0,0,0],[0,1,0,0]]
X = [p, 0, 1, 0]
M = mat_pow(A, n-1, mod)
a = 0
for j in range(4):
    a += M[0][j]*X[j]
    a %= mod
ans = 1-pow(1-a, m, mod)
print(ans%mod)
0