結果
問題 | No.344 ある無理数の累乗 |
ユーザー |
|
提出日時 | 2016-02-13 12:28:13 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 660 bytes |
コンパイル時間 | 367 ms |
コンパイル使用メモリ | 52,020 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 06:13:49 |
合計ジャッジ時間 | 1,226 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.cpp:18:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 18 | main(){ | ^~~~
ソースコード
//icpc2012rC #include <valarray> #include <cstdio> using namespace std; typedef valarray<long long>V; int n=2,m=1000; //lol V z; V &Me(const V &_x,const V &_y){ int i=0,j; for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m; return z; } V &Mx(const V &_x){ int i=0,j; for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_x[slice(j,n,n)]).sum()%m; return z; } main(){ int t=1,T,r; for(;~scanf("%d",&r);){ int f=1-r%2; V x(n*n); V e(n*n); z.resize(n*n); x[0]=1,x[1]=3,x[2]=1,x[3]=1; e[0]=1,e[3]=1; //unit for(;r;r>>=1){ if(r&1)e=Me(e,x); x=Mx(x); } printf("%d\n",(int)(2*e[0]-f)%1000); } }