結果
問題 |
No.1258 コインゲーム
|
ユーザー |
![]() |
提出日時 | 2020-10-16 22:45:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 589 bytes |
コンパイル時間 | 1,817 ms |
コンパイル使用メモリ | 193,180 KB |
最終ジャッジ日時 | 2025-01-15 09:01:06 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 40 |
ソースコード
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; const ll MOD=1e9+7; const ll A=500000004; ll modpow(ll x,ll n){ ll ans=1; while(n){ if(n&1) ans=ans*x %MOD; x=x*x %MOD; n/=2; } return ans; } int main(){ int s; cin>>s; while(s--){ ll n,m; int x; cin>>n>>m>>x; if(x==0){ cout<<(modpow(1+m,n)+modpow(1-m,n))*A%MOD<<endl; } else{ cout<<((modpow(1+m,n)-modpow(1-m,n)+MOD)%MOD)*A%MOD<<endl; } } return 0; }