結果

問題 No.1258 コインゲーム
ユーザー realDivineJKrealDivineJK
提出日時 2020-10-16 21:49:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,906 ms / 2,000 ms
コード長 594 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 7,996 KB
最終ジャッジ日時 2023-09-28 02:51:48
合計ジャッジ時間 55,277 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 352 ms
7,804 KB
testcase_01 AC 431 ms
7,912 KB
testcase_02 AC 174 ms
7,768 KB
testcase_03 AC 1,417 ms
7,996 KB
testcase_04 AC 1,601 ms
7,948 KB
testcase_05 AC 267 ms
7,964 KB
testcase_06 AC 1,175 ms
7,848 KB
testcase_07 AC 128 ms
7,808 KB
testcase_08 AC 108 ms
7,864 KB
testcase_09 AC 591 ms
7,800 KB
testcase_10 AC 1,436 ms
7,956 KB
testcase_11 AC 1,559 ms
7,864 KB
testcase_12 AC 1,138 ms
7,904 KB
testcase_13 AC 364 ms
7,956 KB
testcase_14 AC 122 ms
7,724 KB
testcase_15 AC 1,349 ms
7,908 KB
testcase_16 AC 276 ms
7,804 KB
testcase_17 AC 1,537 ms
7,804 KB
testcase_18 AC 588 ms
7,856 KB
testcase_19 AC 544 ms
7,792 KB
testcase_20 AC 1,182 ms
7,956 KB
testcase_21 AC 1,490 ms
7,840 KB
testcase_22 AC 1,041 ms
7,932 KB
testcase_23 AC 772 ms
7,924 KB
testcase_24 AC 284 ms
7,956 KB
testcase_25 AC 743 ms
7,868 KB
testcase_26 AC 623 ms
7,800 KB
testcase_27 AC 1,438 ms
7,908 KB
testcase_28 AC 377 ms
7,980 KB
testcase_29 AC 405 ms
7,720 KB
testcase_30 AC 1,822 ms
7,808 KB
testcase_31 AC 446 ms
7,800 KB
testcase_32 AC 197 ms
7,788 KB
testcase_33 AC 1,197 ms
7,864 KB
testcase_34 AC 1,507 ms
7,848 KB
testcase_35 AC 518 ms
7,792 KB
testcase_36 AC 1,458 ms
7,740 KB
testcase_37 AC 567 ms
7,864 KB
testcase_38 AC 1,386 ms
7,908 KB
testcase_39 AC 384 ms
7,800 KB
testcase_40 AC 1,865 ms
7,804 KB
testcase_41 AC 1,843 ms
7,740 KB
testcase_42 AC 1,828 ms
7,956 KB
testcase_43 AC 1,832 ms
7,996 KB
testcase_44 AC 1,833 ms
7,804 KB
testcase_45 AC 1,836 ms
7,804 KB
testcase_46 AC 1,845 ms
7,788 KB
testcase_47 AC 1,906 ms
7,804 KB
testcase_48 AC 1,845 ms
7,952 KB
testcase_49 AC 1,834 ms
7,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = int(input())
mod = int(1e9) + 7
def doubling(n, m):
    y = 1
    bas = n
    tmp = m
    while tmp:
        if tmp % 2:
            y *= bas
            y %= mod
        bas *= bas
        bas %= mod
        tmp >>= 1
    return y
def inved(a):
    x, y, u, v, k, l = 1, 0, 0, 1, a, mod
    while l:
        x, y, u, v, k, l = u, v, x - u * (k // l), y - v * (k // l), l, k % l
    return x
i2 = inved(2) % mod
for _ in range(S):
    N, M, X = map(int, input().split())
    sign = 1
    if (N + X) % 2 == 1:
        sign = mod - 1
    print(i2*(doubling(M+1, N)+sign*doubling(M-1, N))%mod)
0