結果
問題 | No.1258 コインゲーム |
ユーザー | OmameBeans |
提出日時 | 2020-10-27 14:04:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 257 ms / 2,000 ms |
コード長 | 2,854 bytes |
コンパイル時間 | 1,509 ms |
コンパイル使用メモリ | 170,676 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-21 21:56:03 |
合計ジャッジ時間 | 11,572 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
5,248 KB |
testcase_01 | AC | 66 ms
5,376 KB |
testcase_02 | AC | 24 ms
5,376 KB |
testcase_03 | AC | 199 ms
5,376 KB |
testcase_04 | AC | 221 ms
5,376 KB |
testcase_05 | AC | 36 ms
5,376 KB |
testcase_06 | AC | 160 ms
5,376 KB |
testcase_07 | AC | 17 ms
5,376 KB |
testcase_08 | AC | 15 ms
5,376 KB |
testcase_09 | AC | 83 ms
5,376 KB |
testcase_10 | AC | 194 ms
5,376 KB |
testcase_11 | AC | 213 ms
5,376 KB |
testcase_12 | AC | 155 ms
5,376 KB |
testcase_13 | AC | 51 ms
5,376 KB |
testcase_14 | AC | 16 ms
5,376 KB |
testcase_15 | AC | 191 ms
5,376 KB |
testcase_16 | AC | 40 ms
5,376 KB |
testcase_17 | AC | 220 ms
5,376 KB |
testcase_18 | AC | 81 ms
5,376 KB |
testcase_19 | AC | 75 ms
5,376 KB |
testcase_20 | AC | 167 ms
5,376 KB |
testcase_21 | AC | 208 ms
5,376 KB |
testcase_22 | AC | 143 ms
5,376 KB |
testcase_23 | AC | 105 ms
5,376 KB |
testcase_24 | AC | 42 ms
5,376 KB |
testcase_25 | AC | 100 ms
5,376 KB |
testcase_26 | AC | 86 ms
5,376 KB |
testcase_27 | AC | 196 ms
5,376 KB |
testcase_28 | AC | 54 ms
5,376 KB |
testcase_29 | AC | 56 ms
5,376 KB |
testcase_30 | AC | 246 ms
5,376 KB |
testcase_31 | AC | 63 ms
5,376 KB |
testcase_32 | AC | 27 ms
5,376 KB |
testcase_33 | AC | 163 ms
5,376 KB |
testcase_34 | AC | 210 ms
5,376 KB |
testcase_35 | AC | 73 ms
5,376 KB |
testcase_36 | AC | 204 ms
5,376 KB |
testcase_37 | AC | 80 ms
5,376 KB |
testcase_38 | AC | 185 ms
5,376 KB |
testcase_39 | AC | 54 ms
5,376 KB |
testcase_40 | AC | 246 ms
5,376 KB |
testcase_41 | AC | 255 ms
5,376 KB |
testcase_42 | AC | 250 ms
5,376 KB |
testcase_43 | AC | 252 ms
5,376 KB |
testcase_44 | AC | 250 ms
5,376 KB |
testcase_45 | AC | 249 ms
5,376 KB |
testcase_46 | AC | 252 ms
5,376 KB |
testcase_47 | AC | 257 ms
5,376 KB |
testcase_48 | AC | 256 ms
5,376 KB |
testcase_49 | AC | 253 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #define REP(i,n) for (int i = 0; i < (n); ++i) template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} using namespace std; using ll = long long; using P = pair<int,int>; using Pl = pair<long long,long long>; using veci = vector<int>; using vecl = vector<long long>; using vecveci = vector<vector<int>>; using vecvecl = vector<vector<long long>>; const int MOD = 1e9+7; const double pi = acos(-1); const ll INF = 1e18; template<int m> struct modint{ unsigned int x; constexpr modint()noexcept:x(){} template<typename T> constexpr modint(T x_)noexcept:x((x_%=m)<0?x_+m:x_){} constexpr unsigned int val()const noexcept{return x;} constexpr modint&operator++()noexcept{if(++x==m)x=0;return*this;} constexpr modint&operator--()noexcept{if(x==0)x=m;--x;return*this;} constexpr modint operator++(int)noexcept{modint res=*this;++*this;return res;} constexpr modint operator--(int)noexcept{modint res=*this;--*this;return res;} constexpr modint&operator+=(const modint&a)noexcept{x+=a.x;if(x>=m)x-=m;return*this;} constexpr modint&operator-=(const modint&a)noexcept{if(x<a.x)x+=m;x-=a.x;return*this;} constexpr modint&operator*=(const modint&a)noexcept{x=(unsigned long long)x*a.x%m;return*this;} constexpr modint&operator/=(const modint&a)noexcept{return*this*=a.inv();} constexpr modint operator+()const noexcept{return*this;} constexpr modint operator-()const noexcept{return modint()-*this;} constexpr modint pow(long long n)const noexcept { if(n<0)return pow(-n).inv(); modint x=*this,r=1; for(;n;x*=x,n>>=1)if(n&1)r*=x; return r; } constexpr modint inv()const noexcept { int s=x,t=m,x=1,u=0; while(t) { int k=s/t; s-=k*t; swap(s,t); x-=k*u; swap(x,u); } return modint(x); } friend constexpr modint operator+(const modint&a,const modint&b){return modint(a)+=b;} friend constexpr modint operator-(const modint&a,const modint&b){return modint(a)-=b;} friend constexpr modint operator*(const modint&a,const modint&b){return modint(a)*=b;} friend constexpr modint operator/(const modint&a,const modint&b){return modint(a)/=b;} friend constexpr bool operator==(const modint&a,const modint&b){return a.x==b.x;} friend constexpr bool operator!=(const modint&a,const modint&b){return a.x!=b.x;} friend ostream&operator<<(ostream&os,const modint&a){return os<<a.x;} friend istream&operator>>(istream&is,modint&a){long long v;is>>v;a=modint(v);return is;} }; using mint = modint<(int)1e9+7>; int main() { int S; cin >> S; while(S--) { int N,X; mint M; cin >> N >> M >> X; mint A = (M+1).pow(N), B = (1-M).pow(N); if(X == 0) cout << (A+B)/2 << endl; else cout << (A-B)/2 << endl; } }