結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー negi_magnetnegi_magnet
提出日時 2015-05-22 22:29:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 237 ms / 5,000 ms
コード長 720 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 71,140 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 09:28:46
合計ジャッジ時間 1,520 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> pii;

int p[6] = {2, 3, 5, 7, 11, 13};
int q[6] = {4, 6, 8, 9, 10, 12};
int P, C;

double solve(int a, int b) {
	if(a==0 && b==0) {
		return 1LL;
	}
	double sum = 0.0;
	if(a==0) {
		rep(i, 6) {
			sum += solve(0, b-1) * q[i];
		}
		sum /= 6.0f;
	}
	else {
		rep(i, 6) {
			sum += solve(a-1, b) * p[i];
		}
		sum /= 6.0f;
	}
	return sum;
}	

int main() {
	cin >> P >> C;
	printf("%.10lf\n", solve(P, C));
	return 0;
}
0