結果

問題 No.1706 Many Bus Stops (hard)
ユーザー qwewe
提出日時 2025-05-14 12:53:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 411 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 82,792 KB
実行使用メモリ 53,924 KB
最終ジャッジ日時 2025-05-14 12:54:53
合計ジャッジ時間 2,844 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other WA * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9 + 7

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

# Compute (1/C)^N mod MOD
inv_C = pow(C, MOD-2, MOD)
inv_C_pow_N = pow(inv_C, N, MOD)

# Probability that a single bus is NOT at bus stop 1 after N steps
prob_not = (1 - inv_C_pow_N) % MOD

# Probability that all M buses are NOT at bus stop 1
prob_all_not = pow(prob_not, M, MOD)

# Result is 1 - prob_all_not
result = (1 - prob_all_not) % MOD
print(result)
0