結果

問題 No.1258 コインゲーム
ユーザー donutholedonuthole
提出日時 2020-10-17 00:52:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,015 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 11,148 KB
最終ジャッジ日時 2023-09-28 07:08:58
合計ジャッジ時間 32,122 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 210 ms
10,888 KB
testcase_01 AC 273 ms
10,944 KB
testcase_02 AC 115 ms
10,960 KB
testcase_03 AC 786 ms
10,896 KB
testcase_04 AC 882 ms
10,816 KB
testcase_05 AC 167 ms
10,964 KB
testcase_06 AC 643 ms
10,984 KB
testcase_07 AC 92 ms
10,816 KB
testcase_08 AC 84 ms
10,896 KB
testcase_09 AC 337 ms
10,916 KB
testcase_10 AC 771 ms
11,044 KB
testcase_11 AC 885 ms
10,932 KB
testcase_12 AC 662 ms
10,920 KB
testcase_13 AC 220 ms
10,932 KB
testcase_14 AC 92 ms
10,884 KB
testcase_15 AC 750 ms
10,948 KB
testcase_16 AC 170 ms
10,852 KB
testcase_17 AC 861 ms
10,924 KB
testcase_18 AC 342 ms
10,968 KB
testcase_19 AC 325 ms
10,984 KB
testcase_20 AC 674 ms
11,148 KB
testcase_21 AC 815 ms
10,964 KB
testcase_22 AC 575 ms
11,016 KB
testcase_23 AC 427 ms
10,960 KB
testcase_24 AC 183 ms
10,940 KB
testcase_25 AC 418 ms
10,980 KB
testcase_26 AC 361 ms
10,944 KB
testcase_27 AC 784 ms
11,044 KB
testcase_28 AC 227 ms
10,968 KB
testcase_29 AC 244 ms
10,944 KB
testcase_30 AC 988 ms
10,920 KB
testcase_31 AC 268 ms
10,932 KB
testcase_32 AC 139 ms
11,088 KB
testcase_33 AC 666 ms
10,980 KB
testcase_34 AC 815 ms
10,964 KB
testcase_35 AC 304 ms
10,852 KB
testcase_36 AC 802 ms
10,952 KB
testcase_37 AC 327 ms
10,892 KB
testcase_38 AC 750 ms
10,964 KB
testcase_39 AC 228 ms
10,948 KB
testcase_40 AC 1,013 ms
10,948 KB
testcase_41 AC 978 ms
10,924 KB
testcase_42 AC 996 ms
11,040 KB
testcase_43 AC 977 ms
10,964 KB
testcase_44 AC 975 ms
10,880 KB
testcase_45 AC 1,015 ms
11,040 KB
testcase_46 AC 1,003 ms
10,932 KB
testcase_47 AC 994 ms
10,964 KB
testcase_48 AC 981 ms
10,820 KB
testcase_49 AC 1,008 ms
10,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import typing
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
# import numpy as np

# sys.setrecursionlimit(10000001)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353


def ni(): return int(sys.stdin.buffer.readline())
def ns(): return map(int, sys.stdin.buffer.readline().split())
def na(): return list(map(int, sys.stdin.buffer.readline().split()))


# ===CODE===

def main():
    s = ni()
    for _ in range(s):
        n, m, x = ns()
        a = pow(1+m, n, MOD)
        b = pow(-1+m, n, MOD)
        if n%2:
            tmp = a+b if x else a-b
        else:
            tmp = a-b if x else a+b

        div = pow(2,MOD-2,MOD)
        ans = tmp*div % MOD
        print(ans)


if __name__ == '__main__':
    main()
0