結果

問題 No.1258 コインゲーム
ユーザー titiatitia
提出日時 2022-06-15 01:23:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 76,776 KB
最終ジャッジ日時 2024-04-14 07:23:34
合計ジャッジ時間 12,597 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
75,896 KB
testcase_01 AC 117 ms
75,904 KB
testcase_02 AC 79 ms
72,784 KB
testcase_03 AC 231 ms
76,032 KB
testcase_04 AC 243 ms
76,220 KB
testcase_05 AC 96 ms
75,920 KB
testcase_06 AC 194 ms
76,536 KB
testcase_07 AC 74 ms
71,356 KB
testcase_08 AC 75 ms
72,348 KB
testcase_09 AC 130 ms
75,884 KB
testcase_10 AC 221 ms
75,980 KB
testcase_11 AC 237 ms
76,108 KB
testcase_12 AC 192 ms
75,840 KB
testcase_13 AC 106 ms
75,980 KB
testcase_14 AC 76 ms
71,476 KB
testcase_15 AC 216 ms
75,928 KB
testcase_16 AC 94 ms
75,928 KB
testcase_17 AC 235 ms
76,000 KB
testcase_18 AC 128 ms
75,976 KB
testcase_19 AC 123 ms
76,260 KB
testcase_20 AC 189 ms
76,360 KB
testcase_21 AC 224 ms
76,308 KB
testcase_22 AC 177 ms
75,820 KB
testcase_23 AC 150 ms
75,904 KB
testcase_24 AC 99 ms
76,168 KB
testcase_25 AC 146 ms
76,320 KB
testcase_26 AC 134 ms
76,120 KB
testcase_27 AC 226 ms
76,064 KB
testcase_28 AC 108 ms
75,988 KB
testcase_29 AC 115 ms
76,000 KB
testcase_30 AC 260 ms
76,256 KB
testcase_31 AC 116 ms
76,100 KB
testcase_32 AC 84 ms
73,988 KB
testcase_33 AC 194 ms
76,060 KB
testcase_34 AC 227 ms
76,776 KB
testcase_35 AC 122 ms
75,984 KB
testcase_36 AC 224 ms
75,992 KB
testcase_37 AC 127 ms
75,908 KB
testcase_38 AC 214 ms
76,240 KB
testcase_39 AC 107 ms
75,824 KB
testcase_40 AC 255 ms
76,216 KB
testcase_41 AC 251 ms
75,872 KB
testcase_42 AC 250 ms
75,876 KB
testcase_43 AC 251 ms
75,956 KB
testcase_44 AC 253 ms
76,212 KB
testcase_45 AC 254 ms
75,804 KB
testcase_46 AC 255 ms
76,276 KB
testcase_47 AC 253 ms
76,028 KB
testcase_48 AC 250 ms
76,216 KB
testcase_49 AC 256 ms
75,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 二項定理を思い付くのが重要
# 二項係数とベキ乗の和が出ている→二項定理か? と思いつけなくてはいけない。

import sys
input = sys.stdin.readline
mod=10**9+7

INV=pow(2,mod-2,mod)

T=int(input())
for tests in range(T):
    N,M,X=map(int,input().split())

    ALL=pow(1+M,N,mod)
    H=pow(-1+M,N,mod)

    if (X+N)%2==0:
        print((ALL+H)*INV%mod)
    else:
        print((ALL-H)*INV%mod)
0