結果

問題 No.1258 コインゲーム
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-09-09 19:48:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 6,350 ms
コンパイル使用メモリ 307,972 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 19:49:05
合計ジャッジ時間 18,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
4,352 KB
testcase_01 AC 70 ms
4,356 KB
testcase_02 AC 26 ms
4,352 KB
testcase_03 AC 224 ms
4,360 KB
testcase_04 AC 252 ms
4,360 KB
testcase_05 AC 42 ms
4,356 KB
testcase_06 AC 183 ms
4,356 KB
testcase_07 AC 19 ms
4,356 KB
testcase_08 AC 16 ms
4,360 KB
testcase_09 AC 94 ms
4,352 KB
testcase_10 AC 223 ms
4,356 KB
testcase_11 AC 246 ms
4,356 KB
testcase_12 AC 179 ms
4,380 KB
testcase_13 AC 56 ms
4,356 KB
testcase_14 AC 19 ms
4,356 KB
testcase_15 AC 219 ms
4,356 KB
testcase_16 AC 48 ms
4,356 KB
testcase_17 AC 244 ms
4,356 KB
testcase_18 AC 89 ms
4,352 KB
testcase_19 AC 83 ms
4,352 KB
testcase_20 AC 184 ms
4,356 KB
testcase_21 AC 232 ms
4,360 KB
testcase_22 AC 162 ms
4,356 KB
testcase_23 AC 117 ms
4,356 KB
testcase_24 AC 44 ms
4,360 KB
testcase_25 AC 112 ms
4,352 KB
testcase_26 AC 95 ms
4,356 KB
testcase_27 AC 228 ms
4,356 KB
testcase_28 AC 58 ms
4,352 KB
testcase_29 AC 63 ms
4,352 KB
testcase_30 AC 284 ms
4,356 KB
testcase_31 AC 69 ms
4,380 KB
testcase_32 AC 31 ms
4,352 KB
testcase_33 AC 185 ms
4,356 KB
testcase_34 AC 230 ms
4,356 KB
testcase_35 AC 81 ms
4,356 KB
testcase_36 AC 224 ms
4,352 KB
testcase_37 AC 89 ms
4,356 KB
testcase_38 AC 210 ms
4,352 KB
testcase_39 AC 60 ms
4,356 KB
testcase_40 AC 276 ms
4,352 KB
testcase_41 AC 275 ms
4,352 KB
testcase_42 AC 279 ms
4,356 KB
testcase_43 AC 277 ms
4,360 KB
testcase_44 AC 273 ms
4,356 KB
testcase_45 AC 280 ms
4,376 KB
testcase_46 AC 283 ms
4,356 KB
testcase_47 AC 275 ms
4,356 KB
testcase_48 AC 277 ms
4,352 KB
testcase_49 AC 279 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint1000000007;
using ll=long long;
using pp=pair<mint,mint>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  ll t;cin>>t;
  rep(z,t){
    ll n,m,x;cin>>n>>m>>x;
    auto merge=[&](pp a,pp b)->pp{
      return {a.fi*b.fi+a.se*b.se,a.fi*b.se+a.se*b.fi};
    };
    pp e={1,m};
    auto f=[&](auto f,ll a)->pair<mint,mint>{
      if(a==1)return e;
      auto res=f(f,a/2);
      res=merge(res,res);
      if(a&1)res=merge(res,e);
      return res;
    };
    pp res=f(f,n);
    if(x==0)cout<<res.fi.val();
    else cout<<res.se.val();
    cout<<"\n";
  }
}
      
0