結果
| 問題 |
No.212 素数サイコロと合成数サイコロ (2)
|
| コンテスト | |
| ユーザー |
negi_magnet
|
| 提出日時 | 2015-05-22 22:29:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 141 ms / 5,000 ms |
| コード長 | 720 bytes |
| コンパイル時間 | 660 ms |
| コンパイル使用メモリ | 76,236 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 05:05:51 |
| 合計ジャッジ時間 | 1,411 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#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;
}
negi_magnet