結果

問題 No.344 ある無理数の累乗
ユーザー ciel
提出日時 2016-02-13 11:50:39
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 52,124 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-22 06:13:19
合計ジャッジ時間 1,211 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:18:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   18 | main(){
      | ^~~~

ソースコード

diff #

//icpc2012rC
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n=2,m=1000;
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("%03d\n",(int)(e[0]+e[2]*1.7320508075688772)%1000);
	}
}
0