結果

問題 No.1258 コインゲーム
ユーザー ocvret_ocvret_
提出日時 2020-10-16 22:36:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 1,296 ms
コンパイル使用メモリ 164,856 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 04:21:39
合計ジャッジ時間 11,524 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
4,380 KB
testcase_01 AC 58 ms
4,376 KB
testcase_02 AC 23 ms
4,376 KB
testcase_03 AC 196 ms
4,380 KB
testcase_04 AC 223 ms
4,376 KB
testcase_05 AC 36 ms
4,376 KB
testcase_06 AC 158 ms
4,376 KB
testcase_07 AC 17 ms
4,380 KB
testcase_08 AC 14 ms
4,376 KB
testcase_09 AC 80 ms
4,380 KB
testcase_10 AC 189 ms
4,376 KB
testcase_11 AC 211 ms
4,380 KB
testcase_12 AC 156 ms
4,376 KB
testcase_13 AC 48 ms
4,380 KB
testcase_14 AC 16 ms
4,380 KB
testcase_15 AC 191 ms
4,380 KB
testcase_16 AC 38 ms
4,376 KB
testcase_17 AC 216 ms
4,380 KB
testcase_18 AC 79 ms
4,376 KB
testcase_19 AC 73 ms
4,376 KB
testcase_20 AC 160 ms
4,376 KB
testcase_21 AC 205 ms
4,380 KB
testcase_22 AC 144 ms
4,376 KB
testcase_23 AC 107 ms
4,380 KB
testcase_24 AC 38 ms
4,380 KB
testcase_25 AC 98 ms
4,376 KB
testcase_26 AC 86 ms
4,376 KB
testcase_27 AC 191 ms
4,376 KB
testcase_28 AC 51 ms
4,376 KB
testcase_29 AC 54 ms
4,376 KB
testcase_30 AC 242 ms
4,380 KB
testcase_31 AC 62 ms
4,380 KB
testcase_32 AC 28 ms
4,380 KB
testcase_33 AC 165 ms
4,380 KB
testcase_34 AC 201 ms
4,376 KB
testcase_35 AC 70 ms
4,376 KB
testcase_36 AC 194 ms
4,376 KB
testcase_37 AC 76 ms
4,376 KB
testcase_38 AC 182 ms
4,376 KB
testcase_39 AC 52 ms
4,376 KB
testcase_40 AC 254 ms
4,380 KB
testcase_41 AC 248 ms
4,376 KB
testcase_42 AC 249 ms
4,380 KB
testcase_43 AC 252 ms
4,376 KB
testcase_44 AC 251 ms
4,380 KB
testcase_45 AC 248 ms
4,376 KB
testcase_46 AC 257 ms
4,380 KB
testcase_47 AC 247 ms
4,376 KB
testcase_48 AC 260 ms
4,380 KB
testcase_49 AC 256 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



ll modpow(ll n,ll r){
  ll res = 1;
  while(r){
    if(r & 1)res = res*n%MOD;
    n = n*n%MOD;
    r >>= 1;
  }
  return res;
}

int main(){
  
  int T;
  cin >> T;
  while(T--){
    int n,m,x;
    cin >> n >> m >> x;
    if((x & 1) == (n & 1)){
      cout << ((modpow(m-1,n)+modpow(m+1,n))%MOD)*modpow(2,MOD-2)%MOD << "\n";
    }else{
      cout << (MOD-modpow(m-1,n)+modpow(m+1,n))%MOD*modpow(2,MOD-2)%MOD << "\n";
    }
  }


  return 0;
}
0