結果

問題 No.1706 Many Bus Stops (hard)
ユーザー titiatitia
提出日時 2021-10-09 05:40:26
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,060 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 840,308 KB
最終ジャッジ日時 2023-09-30 22:29:18
合計ジャッジ時間 3,206 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

mod=10**9+7

# 行列の計算(numpyを使えないとき,modを使用)
def prod(A,B,k,l,m):# A:k*l,B:l*m
    C=[[None for i in range(m)] for j in range(k)]

    for i in range(k):
        for j in range(m):
            ANS=0
            for pl in range(l):
                ANS=(ANS+A[i][pl]*B[pl][j])%mod

            C[i][j]=ANS

    return C

def plus(A,B,k,l):# a,B:k*l
    C=[[None for i in range(l)] for j in range(k)]

    for i in range(k):
        for j in range(l):
            C[i][j]=(A[i][j]+B[i][j])%mod

    return C

C,n,M=map(int,input().split())

INV=pow(C,mod-2,mod)

A=[[0]*(C*2) for i in range(2*C)]

for i in range(C):
    A[i][i]=INV
    for j in range(C,2*C):
        if i+C!=j:
            A[i][j]=INV

for i in range(C):
    A[i+C][i]=1

POWA=[A]
for i in range(60):
    POWA.append(prod(POWA[-1],POWA[-1],2*C,2*C,2*C)) # ベキを求めて


X=[[0]*(C*2)]
X[0][0]=1

while n:
    X=prod(X,POWA[n.bit_length()-1],1,2*C,2*C) # n乗の場合
    n-=1<<(n.bit_length()-1)

#print(X[0][0])

t=X[0][0]

print((1-pow((1-t),M,mod))%mod)
0