結果
| 問題 |
No.147 試験監督(2)
|
| コンテスト | |
| ユーザー |
DAyamaCTF
|
| 提出日時 | 2017-09-21 03:21:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,147 bytes |
| コンパイル時間 | 1,470 ms |
| コンパイル使用メモリ | 165,544 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-11-08 09:29:21 |
| 合計ジャッジ時間 | 4,661 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount
const long long M=1e9+7;
typedef vector<long long> vec;
typedef vector<vec> mat;
struct Matrix{
int N;
mat a;
Matrix(int n){
N=n;
a=mat(N,vec(N));
for(int i=0;i<N;i++)a[i][i]=1;
}
Matrix pow(long long b) const {
Matrix res(N);
Matrix d(N);
for(int i=0;i<N;i++)for(int j=0;j<N;j++)d[i][j]=a[i][j];
for(;b>0;b>>=1,d=d*d)if(b&1)res=d*res;
return res;
}
Matrix operator+(const Matrix& r) const {
Matrix s(N);
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
s[i][j]=(a[i][j]+r.a[i][j])%M;
}
}
return s;
}
Matrix operator*(const Matrix& r) const {
Matrix s(N);
for(int i=0;i<N;i++)s[i][i]=0;
for(int i=0;i<N;i++){
for(int k=0;k<N;k++){
for(int j=0;j<N;j++){
s[i][j]=(s[i][j]+a[i][k]*r.a[k][j])%M;
}
}
}
return s;
}
vector<long long>& operator[](int i){
return a[i];
}
};
ll fib(ll num){
Matrix m(2);
m.a[0][0]=1; m.a[0][1]=1;
m.a[1][0]=1; m.a[1][1]=0;
Matrix res=m.pow(num+1);
return res[0][0]%M;
}
ll mod_pow(ll a,ll n){
ll res=1;
while(n>0){
if(n&1)res=res*a%M;
a=a*a%M;
n>>=1;
}
return res;
}
ll n;
ll c[30001],d[30001];
string ds[30001];
int main(){
cin>>n;
rep(i,n){
cin>>c[i]>>ds[i];
ll sum=0;
rep(j,ds[i].size()){
sum*=10;
sum+=(ds[i][j]-'0');
sum%=M-1;
}
d[i]=sum;
//dbg(d[i]);
}
ll res=1;
rep(i,n){
res=res*mod_pow(fib(c[i]),d[i])%M;
//dbg(res);
}
cout<<res<<endl;
return 0;
}
DAyamaCTF