結果
問題 | No.1258 コインゲーム |
ユーザー |
![]() |
提出日時 | 2022-04-24 11:02:36 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 457 bytes |
コンパイル時間 | 235 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 21,504 KB |
最終ジャッジ日時 | 2024-06-25 21:19:12 |
合計ジャッジ時間 | 9,380 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 49 |
ソースコード
mod = 7+10**9 def ncr(n,c,mod): x = 1 y = 1 for i in range(n-c+1,n+1): x = x*i%mod for j in range(1,c+1): y = y*j%mod return (x * pow(y, mod-2, mod)) % mod S = int(input()) for _ in range(S): n, m, x = map(int, input().split()) count = 0 if x == 1: count = 1 else: count = 2 ans = 0 point = 0 while count <= n: point += (ncr(n, count, mod) * pow(m, count, mod)) point %= mod count += 2 print(point%mod)