結果

問題 No.58 イカサマなサイコロ
ユーザー butsurizukibutsurizuki
提出日時 2016-11-15 19:25:39
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,054 bytes
コンパイル時間 820 ms
コンパイル使用メモリ 26,080 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 07:06:34
合計ジャッジ時間 1,522 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

void cpy(unsigned long long int f[],unsigned long long int t[]){
	int i;
	for(i=0;i<=63;i++){t[i] = f[i];}
}

void res(unsigned long long int d[]){
	int i;
	for(i=0;i<=63;i++){d[i]=0;}
}

unsigned long long int sixpow(int t){
	int i;
	unsigned long long int m=1;
	for(i = 1;i <= t;i++){m*=6;}
	return m;
}

int main(void){
	unsigned long long int x[64]={0},y[64]={0},mx[64]={0},my[64]={0};
	int n,k,i,j,a;
	unsigned long long int t,wt;
	double ans;
	scanf("%d%d",&n,&k);
	x[0]=1;
	mx[0]=1;
	for(i = 1;i <= k;i++){
		res(y);
		res(my);
		for(j = 0;j <= 57;j++){
			for(a = 4;a <= 6;a++){my[j+a]+=(mx[j] * 2);}
			for(a = 1;a <= 6;a++){y[j+a]+=(x[j]);}
		}
		cpy(y,x);
		cpy(my,mx);
	}
	for(i = k+1;i <= n;i++){
		res(y);
		res(my);
		for(j = 0;j <= 57;j++){
			for(a = 1;a <= 6;a++){my[j+a]+=(mx[j]);}
			for(a = 1;a <= 6;a++){y[j+a]+=(x[j]);}
		}
		cpy(y,x);
		cpy(my,mx);
	}
	t = sixpow(n);
	t = t * t;
	for(i=1;i<=62;i++){
		for(j = i+1;j <= 63;j++){
			wt+=(x[i]*mx[j]);
		}
	}
	ans = wt;
	ans/=t;
	printf("%lf\n",ans);
	return 0;
}
0