結果

問題 No.1258 コインゲーム
ユーザー toyuzukotoyuzuko
提出日時 2020-10-16 22:33:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 797 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 10,652 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-09-28 04:20:02
合計ジャッジ時間 25,754 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
7,852 KB
testcase_01 AC 194 ms
7,924 KB
testcase_02 AC 80 ms
7,720 KB
testcase_03 AC 620 ms
7,864 KB
testcase_04 AC 682 ms
7,816 KB
testcase_05 AC 120 ms
7,716 KB
testcase_06 AC 495 ms
7,812 KB
testcase_07 AC 60 ms
7,768 KB
testcase_08 AC 54 ms
7,816 KB
testcase_09 AC 256 ms
7,884 KB
testcase_10 AC 600 ms
7,868 KB
testcase_11 AC 670 ms
7,796 KB
testcase_12 AC 491 ms
7,716 KB
testcase_13 AC 158 ms
7,780 KB
testcase_14 AC 63 ms
7,844 KB
testcase_15 AC 599 ms
7,928 KB
testcase_16 AC 129 ms
7,860 KB
testcase_17 AC 666 ms
7,812 KB
testcase_18 AC 255 ms
7,764 KB
testcase_19 AC 239 ms
7,680 KB
testcase_20 AC 493 ms
7,944 KB
testcase_21 AC 637 ms
7,812 KB
testcase_22 AC 439 ms
7,800 KB
testcase_23 AC 326 ms
7,928 KB
testcase_24 AC 126 ms
7,804 KB
testcase_25 AC 312 ms
7,756 KB
testcase_26 AC 268 ms
7,776 KB
testcase_27 AC 615 ms
7,720 KB
testcase_28 AC 172 ms
7,776 KB
testcase_29 AC 183 ms
7,796 KB
testcase_30 AC 772 ms
7,752 KB
testcase_31 AC 195 ms
7,864 KB
testcase_32 AC 92 ms
7,876 KB
testcase_33 AC 506 ms
7,852 KB
testcase_34 AC 637 ms
7,736 KB
testcase_35 AC 229 ms
7,812 KB
testcase_36 AC 619 ms
7,764 KB
testcase_37 AC 250 ms
7,840 KB
testcase_38 AC 578 ms
7,936 KB
testcase_39 AC 168 ms
7,792 KB
testcase_40 AC 779 ms
7,816 KB
testcase_41 AC 785 ms
7,760 KB
testcase_42 AC 776 ms
7,736 KB
testcase_43 AC 771 ms
7,912 KB
testcase_44 AC 780 ms
7,792 KB
testcase_45 AC 773 ms
7,772 KB
testcase_46 AC 797 ms
7,732 KB
testcase_47 AC 776 ms
7,932 KB
testcase_48 AC 783 ms
7,948 KB
testcase_49 AC 774 ms
7,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

MOD = 1000000007
inv2 = pow(2, MOD - 2, MOD)

S = int(input())

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