結果
| 問題 |
No.344 ある無理数の累乗
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-13 12:26:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 697 bytes |
| コンパイル時間 | 511 ms |
| コンパイル使用メモリ | 52,708 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 06:13:46 |
| 合計ジャッジ時間 | 1,406 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 15 |
コンパイルメッセージ
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=100000000; //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);){
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])%1000);
//printf("%d %d %d %d\n",e[0],e[1],e[2],e[3]);
}
}