結果
| 問題 |
No.147 試験監督(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-04 08:38:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 814 bytes |
| コンパイル時間 | 457 ms |
| コンパイル使用メモリ | 66,048 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 23:30:26 |
| 合計ジャッジ時間 | 3,977 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 1 |
コンパイルメッセージ
main.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
17 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
long mod=1e9+7;
struct Mat{long A[2][2];};
Mat E;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
Mat Mmul(Mat a,Mat b){
Mat ret;
for(int i=0;i<2;i++)for(int j=0;j<2;j++)ret.A[i][j]=0;
for(int i=0;i<2;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)
{
(ret.A[i][j]+=a.A[i][k]*b.A[k][j])%=mod;
}
return ret;
}
Mat Mpow(Mat a,long b){return b?Mmul(Mpow(Mmul(a,a),b/2),b%2?a:E):E;}
main()
{
E.A[0][0]=E.A[1][1]=1;
E.A[0][1]=E.A[1][0]=0;
int N;cin>>N;
long ans=1;
for(;N--;)
{
long C;cin>>C;
Mat f;
f.A[0][0]=f.A[0][1]=f.A[1][0]=1;
f.A[1][1]=0;
f=Mpow(f,C);
long T=(f.A[0][0]+f.A[1][0])%mod;
string Ds;cin>>Ds;
long D=0;
for(int i=0;i<Ds.size();i++)D=(D*10+Ds[i]-'0')%(mod-1);
ans=ans*power(T,D)%mod;
}
cout<<ans<<endl;
}