結果
| 問題 |
No.147 試験監督(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-09 17:27:06 |
| 言語 | Ruby (3.4.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,155 bytes |
| コンパイル時間 | 214 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 127,356 KB |
| 最終ジャッジ日時 | 2024-06-23 16:28:45 |
| 合計ジャッジ時間 | 6,284 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 4 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/bin/ruby
IO.popen('g++ -xc++ -O2 -ozzz - -lgmpxx -lgmp','w'){|io|
io.puts DATA.read
}
IO.popen('./zzz','r+'){|io|
io.write $<.read
io.close_write
puts io.read
}
File.unlink('zzz')
__END__
#include <iostream>
#include <valarray>
#include <gmpxx.h>
using namespace std;
typedef mpz_class val_t;
//typedef long long val_t;
typedef valarray<val_t>V;
const int MOD=1000000007;
V z(4);
V &Me(const V &_x,const V &_y){
int i=0,j;
for(;i<2;i++)for(j=0;j<2;j++)z[i*2+j]=(_x[slice(i*2,2,1)]*_y[slice(j,2,2)]).sum()%MOD;
return z;
}
V &Mx(const V &_x){
int i=0,j;
for(;i<2;i++)for(j=0;j<2;j++)z[i*2+j]=(_x[slice(i*2,2,1)]*_x[slice(j,2,2)]).sum()%MOD;
return z;
}
val_t pow_binary_mod(val_t x,val_t y){
val_t z=1;
for(;y!=0;y>>=1){
if((y&1)!=0)z=z*x%MOD;
x=x*x%MOD;
}
return z;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int T;
val_t r=1;
for(cin>>T;T--;){
val_t c,d;
cin>>c>>d;
if(d>MOD-1)d%=MOD-1;
val_t fib;
{
V x(4);x[0]=x[1]=x[2]=1;
V e(4);e[0]=e[3]=1;
for(c-=1;c!=0;c>>=1){
if((c&1)!=0)e=Me(e,x);
x=Mx(x);
}
fib=e.sum()%MOD;
}
r=r*pow_binary_mod(fib,d)%MOD;
}
cout<<r<<endl;
}