結果

問題 No.1706 Many Bus Stops (hard)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-10-09 17:27:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 611 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 86,884 KB
実行使用メモリ 76,484 KB
最終ジャッジ日時 2023-10-11 04:04:42
合計ジャッジ時間 7,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,272 KB
testcase_01 AC 80 ms
71,328 KB
testcase_02 AC 84 ms
76,232 KB
testcase_03 AC 85 ms
76,120 KB
testcase_04 AC 90 ms
76,132 KB
testcase_05 AC 90 ms
76,236 KB
testcase_06 AC 82 ms
75,956 KB
testcase_07 AC 85 ms
76,128 KB
testcase_08 AC 85 ms
76,276 KB
testcase_09 AC 84 ms
76,232 KB
testcase_10 AC 84 ms
76,196 KB
testcase_11 AC 83 ms
76,404 KB
testcase_12 AC 86 ms
76,284 KB
testcase_13 AC 89 ms
76,208 KB
testcase_14 AC 84 ms
76,332 KB
testcase_15 AC 83 ms
76,256 KB
testcase_16 AC 86 ms
76,236 KB
testcase_17 AC 84 ms
76,100 KB
testcase_18 AC 83 ms
76,096 KB
testcase_19 AC 87 ms
76,124 KB
testcase_20 AC 85 ms
76,232 KB
testcase_21 AC 84 ms
76,420 KB
testcase_22 AC 83 ms
76,208 KB
testcase_23 AC 83 ms
76,192 KB
testcase_24 AC 83 ms
76,432 KB
testcase_25 AC 86 ms
76,144 KB
testcase_26 AC 86 ms
76,208 KB
testcase_27 AC 88 ms
76,152 KB
testcase_28 AC 86 ms
76,236 KB
testcase_29 AC 84 ms
76,416 KB
testcase_30 AC 88 ms
76,208 KB
testcase_31 AC 83 ms
76,196 KB
testcase_32 AC 81 ms
76,124 KB
testcase_33 AC 85 ms
76,232 KB
testcase_34 AC 88 ms
76,232 KB
testcase_35 AC 88 ms
76,416 KB
testcase_36 AC 87 ms
76,208 KB
testcase_37 AC 83 ms
76,348 KB
testcase_38 AC 83 ms
76,348 KB
testcase_39 AC 81 ms
76,484 KB
testcase_40 AC 81 ms
76,140 KB
testcase_41 AC 83 ms
76,368 KB
testcase_42 AC 85 ms
76,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

c,n,m = map(int,input().split())
mod = 10**9+7

cinv = pow(c,mod-2,mod)
A = [[cinv,0,0,cinv],[0,cinv,(c-1)*cinv%mod,(c-2)*cinv%mod],[1,0,0,0],[0,1,0,0]]

def calc(X,Y):
    ans = [[0]*4 for i in range(4)]
    for i in range(4):
        for j in range(4):
            for k in range(4):
                ans[i][j] += X[i][k]*Y[k][j]
                ans[i][j] %= mod
    return ans


base = [[0]*4 for i in range(4)]
for i in range(4):
    base[i][i] = 1

while n:
    if n%2:
        base = calc(A,base)

    n //= 2
    A = calc(A,A)

p = (base[2][0]*cinv+base[2][2])%mod

ans = (1-pow(1-p,m,mod))%mod
print(ans)
0