結果

問題 No.1258 コインゲーム
ユーザー mkawa2mkawa2
提出日時 2021-11-05 13:43:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 952 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-23 21:17:01
合計ジャッジ時間 29,792 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 220 ms
10,752 KB
testcase_01 AC 267 ms
10,624 KB
testcase_02 AC 114 ms
10,624 KB
testcase_03 AC 753 ms
10,752 KB
testcase_04 AC 834 ms
10,880 KB
testcase_05 AC 157 ms
10,880 KB
testcase_06 AC 658 ms
10,752 KB
testcase_07 AC 92 ms
10,880 KB
testcase_08 AC 77 ms
10,752 KB
testcase_09 AC 312 ms
10,880 KB
testcase_10 AC 721 ms
10,752 KB
testcase_11 AC 823 ms
10,880 KB
testcase_12 AC 604 ms
10,752 KB
testcase_13 AC 206 ms
10,752 KB
testcase_14 AC 81 ms
10,624 KB
testcase_15 AC 704 ms
10,752 KB
testcase_16 AC 156 ms
10,880 KB
testcase_17 AC 796 ms
10,752 KB
testcase_18 AC 305 ms
10,624 KB
testcase_19 AC 281 ms
10,752 KB
testcase_20 AC 607 ms
10,752 KB
testcase_21 AC 767 ms
10,752 KB
testcase_22 AC 529 ms
10,752 KB
testcase_23 AC 400 ms
10,752 KB
testcase_24 AC 161 ms
10,752 KB
testcase_25 AC 379 ms
10,752 KB
testcase_26 AC 331 ms
10,880 KB
testcase_27 AC 733 ms
10,880 KB
testcase_28 AC 205 ms
10,752 KB
testcase_29 AC 222 ms
10,752 KB
testcase_30 AC 901 ms
10,752 KB
testcase_31 AC 242 ms
10,880 KB
testcase_32 AC 120 ms
10,752 KB
testcase_33 AC 607 ms
10,752 KB
testcase_34 AC 757 ms
10,752 KB
testcase_35 AC 273 ms
10,752 KB
testcase_36 AC 738 ms
10,880 KB
testcase_37 AC 298 ms
10,880 KB
testcase_38 AC 693 ms
10,880 KB
testcase_39 AC 209 ms
10,624 KB
testcase_40 AC 911 ms
10,752 KB
testcase_41 AC 903 ms
10,752 KB
testcase_42 AC 910 ms
10,752 KB
testcase_43 AC 908 ms
10,752 KB
testcase_44 AC 920 ms
10,624 KB
testcase_45 AC 933 ms
10,880 KB
testcase_46 AC 934 ms
10,880 KB
testcase_47 AC 946 ms
10,752 KB
testcase_48 AC 952 ms
10,880 KB
testcase_49 AC 928 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n", end="\n\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 18446744073709551615
# inf = 4294967295
md = 10**9+7
# md = 998244353

def solve():
    n, m, x = LI()
    s = pow(m+1, n, md)
    t = pow(m-1, n, md)
    if n & 1 == x:
        print((s+t)*inv%md)
    else:
        print((s-t)*inv%md)

inv = (1+md)//2
for _ in range(II()):
    solve()
0