結果
| 問題 |
No.147 試験監督(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-09 17:57:29 |
| 言語 | Ruby (3.4.1) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 752 bytes |
| コンパイル時間 | 192 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 124,068 KB |
| 最終ジャッジ日時 | 2024-06-23 16:31:07 |
| 合計ジャッジ時間 | 5,495 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 4 |
コンパイルメッセージ
Syntax OK
ソースコード
IO.popen('g++ -xc++ -O2 -oZ - -lgmpxx -lgmp','w'){|io|io.puts DATA.read}
IO.popen('./Z','r+'){|io|io.write $<.read;io.close_write;puts io.read}
File.unlink('Z')
__END__
#include<iostream>
#include<valarray>
#include<gmpxx.h>
using namespace std;
typedef valarray<long long>V;
int M=1000000007;
V z(4);
V &g(const V &_x,const V &_y){
for(int i=0,j;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()%M;
return z;
}
main(){
ios::sync_with_stdio(false);
long long T,r=1,c,z;
for(cin>>T;T--;){
mpz_class d;
cin>>c>>d;
if(d>M-1)d%=M-1;
V x(4),e(4);
x[0]=x[1]=x[2]=e[0]=e[3]=1;
for(c--;c;x=g(x,x),c>>=1)if(c&1)e=g(e,x);
c=e.sum()%M;
for(z=1;d!=0;c=c*c%M,d>>=1)if((d&1)!=0)z=z*c%M;
r=r*z%M;
}
cout<<r<<endl;
}