結果

問題 No.1258 コインゲーム
ユーザー H3PO4H3PO4
提出日時 2022-02-03 09:12:16
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 785 ms / 2,000 ms
コード長 306 bytes
コンパイル時間 462 ms
コンパイル使用メモリ 10,632 KB
実行使用メモリ 8,312 KB
最終ジャッジ日時 2023-09-02 03:05:57
合計ジャッジ時間 29,681 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
8,244 KB
testcase_01 AC 206 ms
8,228 KB
testcase_02 AC 83 ms
8,252 KB
testcase_03 AC 654 ms
8,304 KB
testcase_04 AC 717 ms
8,300 KB
testcase_05 AC 124 ms
8,244 KB
testcase_06 AC 517 ms
8,304 KB
testcase_07 AC 65 ms
8,232 KB
testcase_08 AC 53 ms
8,248 KB
testcase_09 AC 264 ms
8,216 KB
testcase_10 AC 621 ms
8,236 KB
testcase_11 AC 695 ms
8,308 KB
testcase_12 AC 509 ms
8,256 KB
testcase_13 AC 163 ms
8,212 KB
testcase_14 AC 62 ms
8,308 KB
testcase_15 AC 608 ms
8,252 KB
testcase_16 AC 130 ms
8,252 KB
testcase_17 AC 682 ms
8,224 KB
testcase_18 AC 264 ms
8,180 KB
testcase_19 AC 240 ms
8,252 KB
testcase_20 AC 510 ms
8,248 KB
testcase_21 AC 649 ms
8,236 KB
testcase_22 AC 457 ms
8,176 KB
testcase_23 AC 335 ms
8,256 KB
testcase_24 AC 132 ms
8,180 KB
testcase_25 AC 321 ms
8,248 KB
testcase_26 AC 281 ms
8,300 KB
testcase_27 AC 644 ms
8,248 KB
testcase_28 AC 175 ms
8,296 KB
testcase_29 AC 183 ms
8,248 KB
testcase_30 AC 779 ms
8,236 KB
testcase_31 AC 205 ms
8,232 KB
testcase_32 AC 94 ms
8,308 KB
testcase_33 AC 523 ms
8,248 KB
testcase_34 AC 643 ms
8,248 KB
testcase_35 AC 239 ms
8,232 KB
testcase_36 AC 635 ms
8,164 KB
testcase_37 AC 259 ms
8,312 KB
testcase_38 AC 605 ms
8,192 KB
testcase_39 AC 172 ms
8,176 KB
testcase_40 AC 782 ms
8,252 KB
testcase_41 AC 774 ms
8,232 KB
testcase_42 AC 785 ms
8,256 KB
testcase_43 AC 780 ms
8,168 KB
testcase_44 AC 785 ms
8,252 KB
testcase_45 AC 771 ms
8,232 KB
testcase_46 AC 773 ms
8,312 KB
testcase_47 AC 783 ms
8,168 KB
testcase_48 AC 776 ms
8,248 KB
testcase_49 AC 771 ms
8,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline

MOD = 1_000_000_007
p2 = pow(2, -1, MOD)


def solve(N, M, X):
    p = pow(1 + M, N, MOD)
    m = pow(1 - M, N, MOD)
    return (p - m) * p2 % MOD if X else (p + m) * p2 % MOD


S = int(input())
for _ in range(S):
    print(solve(*map(int, input().split())))
0