結果

問題 No.1258 コインゲーム
ユーザー jensenjensen
提出日時 2021-01-09 13:45:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,251 ms / 2,000 ms
コード長 362 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 54,016 KB
最終ジャッジ日時 2024-11-17 17:02:00
合計ジャッジ時間 36,640 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

k=int(input())
num_list=[map(int,input().split()) for i in range(k)]
mod=10**9+7

for i in range(k):
    [n,m,x]=num_list[i]
    if(x==0):
        a=pow(1+m,n,mod)+pow(1-m,n,mod)
        if(a%2==1):
            a+=mod
        a=int(a/2)
    else:
        a=pow(1+m,n,mod)-pow(1-m,n,mod)
        if(a%2==1):
            a+=mod
        a=int(a/2)

    print(a%mod)
0