結果
| 問題 |
No.1258 コインゲーム
|
| コンテスト | |
| ユーザー |
mot
|
| 提出日時 | 2020-10-17 04:03:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,014 bytes |
| コンパイル時間 | 1,372 ms |
| コンパイル使用メモリ | 83,980 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-21 01:47:39 |
| 合計ジャッジ時間 | 16,057 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 40 |
ソースコード
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);
ll mypow(ll a, ll b) {
ll ans = 1;
ll two;
ll tmp;
while(b>0) {
two = 1;
tmp = a;
while(2*two<b) {
two *= 2;
tmp *= tmp;
tmp %= mod;
}
b -= two;
ans *= tmp;
ans %= mod;
}
return ans;
}
int main() {
int S;
cin>>S;
ll ans[S];
ll N, M, X;
for(int i=0;i<S;++i) {
cin>>N>>M>>X;
if(X==1) ans[i] = (mypow(1+M, N)-mypow(1-M, N)+mod)%mod*mypow(2, mod-2)%mod;
else ans[i] = (mypow(1+M, N)+mypow(1-M, N))%mod*mypow(2, mod-2)%mod;
}
for(int i=0;i<S;++i) cout<<ans[i]<<endl;
}
mot