結果

問題 No.1258 コインゲーム
ユーザー tonyu0tonyu0
提出日時 2020-10-17 02:18:14
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,598 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,596 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2023-09-28 07:15:52
合計ジャッジ時間 49,210 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 318 ms
7,968 KB
testcase_01 AC 388 ms
7,924 KB
testcase_02 AC 149 ms
7,864 KB
testcase_03 AC 1,256 ms
7,984 KB
testcase_04 AC 1,429 ms
7,788 KB
testcase_05 AC 241 ms
7,920 KB
testcase_06 AC 1,035 ms
7,844 KB
testcase_07 AC 114 ms
7,828 KB
testcase_08 AC 99 ms
7,784 KB
testcase_09 AC 520 ms
7,952 KB
testcase_10 AC 1,232 ms
7,860 KB
testcase_11 AC 1,367 ms
7,924 KB
testcase_12 AC 1,007 ms
7,784 KB
testcase_13 AC 321 ms
7,856 KB
testcase_14 AC 110 ms
7,780 KB
testcase_15 AC 1,233 ms
7,832 KB
testcase_16 AC 247 ms
7,860 KB
testcase_17 AC 1,379 ms
7,852 KB
testcase_18 AC 514 ms
7,844 KB
testcase_19 AC 473 ms
7,868 KB
testcase_20 AC 1,013 ms
7,896 KB
testcase_21 AC 1,278 ms
7,860 KB
testcase_22 AC 894 ms
7,812 KB
testcase_23 AC 665 ms
7,864 KB
testcase_24 AC 254 ms
7,952 KB
testcase_25 AC 643 ms
7,932 KB
testcase_26 AC 541 ms
7,852 KB
testcase_27 AC 1,262 ms
7,784 KB
testcase_28 AC 332 ms
7,840 KB
testcase_29 AC 354 ms
7,784 KB
testcase_30 AC 1,553 ms
7,864 KB
testcase_31 AC 392 ms
7,916 KB
testcase_32 AC 180 ms
7,864 KB
testcase_33 AC 1,046 ms
7,784 KB
testcase_34 AC 1,300 ms
7,848 KB
testcase_35 AC 449 ms
7,864 KB
testcase_36 AC 1,260 ms
7,812 KB
testcase_37 AC 496 ms
7,916 KB
testcase_38 AC 1,184 ms
7,780 KB
testcase_39 AC 346 ms
7,788 KB
testcase_40 AC 1,582 ms
7,884 KB
testcase_41 AC 1,583 ms
7,828 KB
testcase_42 AC 1,583 ms
7,820 KB
testcase_43 AC 1,589 ms
7,840 KB
testcase_44 AC 1,572 ms
7,960 KB
testcase_45 AC 1,582 ms
7,952 KB
testcase_46 AC 1,598 ms
7,868 KB
testcase_47 AC 1,594 ms
7,920 KB
testcase_48 AC 1,595 ms
7,980 KB
testcase_49 AC 1,575 ms
7,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
s = int(input())

for i in range(s):
    n, m, k = map(int, input().split())
    # ΣnCk*m^k*1^(n-k)=(1+m)^n
    res = pow(m + 1, n, mod)
    if k:  # mの奇数乗が残る
        res = (res - pow(1 - m, n, mod)) % mod
    else:
        res = (res + pow(1 - m, n, mod)) % mod
    res = res * pow(2, mod - 2, mod) % mod
    print(res)
0