結果

問題 No.1258 コインゲーム
ユーザー roarisroaris
提出日時 2020-11-17 18:43:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 278 ms / 2,000 ms
コード長 288 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 77,756 KB
最終ジャッジ日時 2023-09-30 14:22:01
合計ジャッジ時間 16,707 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
77,408 KB
testcase_01 AC 139 ms
77,356 KB
testcase_02 AC 110 ms
77,516 KB
testcase_03 AC 241 ms
77,416 KB
testcase_04 AC 260 ms
77,664 KB
testcase_05 AC 119 ms
77,468 KB
testcase_06 AC 212 ms
77,400 KB
testcase_07 AC 104 ms
76,972 KB
testcase_08 AC 102 ms
76,996 KB
testcase_09 AC 152 ms
77,532 KB
testcase_10 AC 241 ms
77,636 KB
testcase_11 AC 257 ms
77,536 KB
testcase_12 AC 211 ms
77,500 KB
testcase_13 AC 129 ms
77,400 KB
testcase_14 AC 102 ms
76,996 KB
testcase_15 AC 233 ms
77,288 KB
testcase_16 AC 122 ms
77,608 KB
testcase_17 AC 254 ms
77,668 KB
testcase_18 AC 153 ms
77,524 KB
testcase_19 AC 147 ms
77,528 KB
testcase_20 AC 212 ms
77,548 KB
testcase_21 AC 248 ms
77,612 KB
testcase_22 AC 199 ms
77,664 KB
testcase_23 AC 174 ms
77,624 KB
testcase_24 AC 121 ms
77,508 KB
testcase_25 AC 168 ms
77,432 KB
testcase_26 AC 158 ms
77,248 KB
testcase_27 AC 243 ms
77,564 KB
testcase_28 AC 132 ms
77,460 KB
testcase_29 AC 135 ms
77,456 KB
testcase_30 AC 278 ms
77,676 KB
testcase_31 AC 140 ms
77,284 KB
testcase_32 AC 112 ms
77,432 KB
testcase_33 AC 216 ms
77,588 KB
testcase_34 AC 247 ms
77,568 KB
testcase_35 AC 143 ms
77,656 KB
testcase_36 AC 242 ms
77,652 KB
testcase_37 AC 152 ms
77,472 KB
testcase_38 AC 239 ms
77,712 KB
testcase_39 AC 135 ms
77,260 KB
testcase_40 AC 268 ms
77,756 KB
testcase_41 AC 267 ms
77,520 KB
testcase_42 AC 270 ms
77,664 KB
testcase_43 AC 269 ms
77,712 KB
testcase_44 AC 270 ms
77,280 KB
testcase_45 AC 271 ms
77,504 KB
testcase_46 AC 271 ms
77,504 KB
testcase_47 AC 268 ms
77,572 KB
testcase_48 AC 271 ms
77,612 KB
testcase_49 AC 267 ms
77,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

S = int(input())
MOD = 10**9+7
inv2 = pow(2, MOD-2, MOD)

for _ in range(S):
    N, M, X = map(int, input().split())
    P = pow(1+M, N, MOD)
    E = (P+pow(1-M, N, MOD))*inv2%MOD
    
    if X==0:
        print(E)
    else:
        print((P-E)%MOD)
0