結果
問題 | No.1275 綺麗な式 |
ユーザー | kotatsugame |
提出日時 | 2020-11-07 23:37:29 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 3,156 bytes |
コンパイル時間 | 683 ms |
コンパイル使用メモリ | 67,880 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-22 14:56:11 |
合計ジャッジ時間 | 2,428 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 1 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 1 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 1 ms
6,940 KB |
testcase_26 | AC | 1 ms
6,944 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 2 ms
6,944 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 2 ms
6,944 KB |
testcase_32 | AC | 1 ms
6,944 KB |
testcase_33 | AC | 2 ms
6,944 KB |
testcase_34 | AC | 2 ms
6,944 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 2 ms
6,944 KB |
testcase_37 | AC | 2 ms
6,940 KB |
testcase_38 | AC | 1 ms
6,944 KB |
testcase_39 | AC | 2 ms
6,944 KB |
testcase_40 | AC | 2 ms
6,940 KB |
testcase_41 | AC | 2 ms
6,940 KB |
testcase_42 | AC | 1 ms
6,944 KB |
testcase_43 | AC | 2 ms
6,944 KB |
testcase_44 | AC | 1 ms
6,944 KB |
testcase_45 | AC | 2 ms
6,940 KB |
testcase_46 | AC | 1 ms
6,940 KB |
testcase_47 | AC | 2 ms
6,940 KB |
testcase_48 | AC | 2 ms
6,940 KB |
testcase_49 | AC | 2 ms
6,940 KB |
testcase_50 | AC | 1 ms
6,940 KB |
testcase_51 | AC | 2 ms
6,940 KB |
testcase_52 | AC | 2 ms
6,944 KB |
testcase_53 | AC | 1 ms
6,944 KB |
testcase_54 | AC | 2 ms
6,940 KB |
testcase_55 | AC | 1 ms
6,944 KB |
testcase_56 | AC | 2 ms
6,944 KB |
testcase_57 | AC | 1 ms
6,944 KB |
testcase_58 | AC | 2 ms
6,940 KB |
testcase_59 | AC | 1 ms
6,944 KB |
testcase_60 | AC | 2 ms
6,940 KB |
testcase_61 | AC | 2 ms
6,940 KB |
コンパイルメッセージ
a.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
ソースコード
#line 1 "a.cpp" #include<iostream> using namespace std; #line 3 "/home/kotatsugame/library/math/modint.cpp" #include<utility> 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;} }; #line 1 "/home/kotatsugame/library/math/squarematrix.cpp" #include<array> template<typename T,unsigned int N> struct Matrix{ array<array<T,N>,N>dat; array<T,N>&operator[](int i){return dat[i];} const array<T,N>&operator[](int i)const{return dat[i];} static Matrix eye(){ Matrix res; for(int i=0;i<N;i++)res[i][i]=1; return res; } Matrix operator+(const Matrix&A)const{ Matrix res; for(int i=0;i<N;i++)for(int j=0;j<N;j++) res[i][j]=dat[i][j]+A[i][j]; return res; } Matrix operator*(const Matrix&A)const{ Matrix res; for(int i=0;i<N;i++)for(int j=0;j<N;j++)for(int k=0;k<N;k++) res[i][j]+=dat[i][k]*A[k][j]; return res; } Matrix pow(long long n)const{ Matrix a=*this,res=eye(); for(;n;a=a*a,n>>=1)if(n&1)res=res*a; return res; } }; #line 5 "a.cpp" using mint=modint<(int)1e9+7>; using mat=Matrix<mint,2>; main() { long a,b,n;cin>>a>>b>>n; if(n==0)cout<<2<<endl; else { mat now; now[0][0]=2*a; now[0][1]=b-a*a; now[1][0]=1; now=now.pow(n-1); cout<<now[0][0]*2*a+now[0][1]*2<<endl; } }