結果

問題 No.1258 コインゲーム
ユーザー realDivineJKrealDivineJK
提出日時 2020-10-16 21:53:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 594 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 79,324 KB
最終ジャッジ日時 2023-09-28 02:58:28
合計ジャッジ時間 17,231 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 173 ms
79,108 KB
testcase_01 AC 187 ms
79,164 KB
testcase_02 AC 150 ms
79,200 KB
testcase_03 AC 323 ms
79,004 KB
testcase_04 AC 361 ms
79,116 KB
testcase_05 AC 162 ms
79,120 KB
testcase_06 AC 302 ms
78,808 KB
testcase_07 AC 144 ms
79,116 KB
testcase_08 AC 143 ms
79,012 KB
testcase_09 AC 212 ms
79,256 KB
testcase_10 AC 329 ms
78,956 KB
testcase_11 AC 354 ms
78,964 KB
testcase_12 AC 285 ms
78,808 KB
testcase_13 AC 175 ms
79,028 KB
testcase_14 AC 141 ms
79,100 KB
testcase_15 AC 313 ms
79,008 KB
testcase_16 AC 163 ms
78,876 KB
testcase_17 AC 343 ms
79,264 KB
testcase_18 AC 211 ms
79,020 KB
testcase_19 AC 208 ms
79,108 KB
testcase_20 AC 290 ms
79,040 KB
testcase_21 AC 339 ms
78,992 KB
testcase_22 AC 276 ms
78,808 KB
testcase_23 AC 237 ms
79,148 KB
testcase_24 AC 169 ms
78,888 KB
testcase_25 AC 236 ms
79,036 KB
testcase_26 AC 209 ms
79,144 KB
testcase_27 AC 329 ms
78,868 KB
testcase_28 AC 175 ms
79,084 KB
testcase_29 AC 177 ms
79,120 KB
testcase_30 AC 373 ms
79,124 KB
testcase_31 AC 186 ms
79,008 KB
testcase_32 AC 150 ms
78,916 KB
testcase_33 AC 292 ms
79,080 KB
testcase_34 AC 329 ms
79,064 KB
testcase_35 AC 195 ms
78,972 KB
testcase_36 AC 337 ms
79,188 KB
testcase_37 AC 208 ms
79,208 KB
testcase_38 AC 315 ms
79,324 KB
testcase_39 AC 172 ms
79,148 KB
testcase_40 AC 349 ms
78,444 KB
testcase_41 AC 350 ms
78,580 KB
testcase_42 AC 353 ms
78,564 KB
testcase_43 AC 362 ms
78,512 KB
testcase_44 AC 351 ms
78,464 KB
testcase_45 AC 350 ms
78,516 KB
testcase_46 AC 352 ms
78,344 KB
testcase_47 AC 360 ms
78,540 KB
testcase_48 AC 350 ms
78,444 KB
testcase_49 AC 358 ms
78,516 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