結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-12 21:33:36
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 362 ms / 5,000 ms
コード長 700 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 25,024 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 14:30:06
合計ジャッジ時間 1,517 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int dices[12];
long long int sum = 0;

void saiki(long long int mul, int diceNum, int diceMax){
	int i;
	int dice[2][6] = {
		{2,3,5,7,11,13},
		{4,6,8,9,10,12}
	};
	
	if( diceMax == diceNum ){
		sum += mul;
		return;
	}
	
	for(i=0;i<6;i++){
		saiki( mul * dice[dices[diceNum]][i], diceNum+1, diceMax);
	}
	return;
}

int main(void){
	long long int mul = 1;
	int a;
	double b,c;
	int i,p,q;
	
	scanf("%d %d", &p, &q);
	for(i=0;i<q;i++){
		dices[i] = 1;
	}
	for(i=0;i<(p+q);i++){
		mul *= 6;
	}
	
	saiki(1, 0, p+q);
	
	c = (double)mul;
	
	a = (int)(sum / mul);	// 整数部
	b = (int)(sum % mul);	// 小数部
	b = b / c;
	b = b + (double)a;
	
	printf("%.10f\n", b);
	return 0;
}
0