結果

問題 No.344 ある無理数の累乗
ユーザー cielciel
提出日時 2016-02-13 11:50:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 53,520 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 04:56:30
合計ジャッジ時間 1,423 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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