結果
| 問題 |
No.212 素数サイコロと合成数サイコロ (2)
|
| コンテスト | |
| ユーザー |
airis
|
| 提出日時 | 2015-05-22 23:12:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,211 bytes |
| コンパイル時間 | 656 ms |
| コンパイル使用メモリ | 84,816 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 05:31:23 |
| 合計ジャッジ時間 | 1,187 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <numeric>
#include <bitset>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
ll a[] = {2,3,5,7,11,13};
ll b[] = {4,6,8,9,10,12};
map<ll, ll> freq1, freq2;
void dfs1(ll n, ll p) {
if (n == 0) {
freq1[p] += 1;
} else {
rep(i, 6) {
dfs1(n-1, p * a[i]);
}
}
}
void dfs2(ll n, ll p) {
if (n == 0) {
freq2[p] += 1;
} else {
rep(i, 6) {
dfs2(n-1, p * b[i]);
}
}
}
ll P, C;
double A = 0.0;
double B = 1.0;
int main() {
cin >> P >> C;
rep(i, P+C) B *= 6.0;
dfs1(P, 1);
dfs2(C, 1);
foreach(i, freq1) {
foreach(j, freq2) {
//printf("%lld=%lld %lld=%lld\n", i->first, i->second, j->first, j->second);
A += (i->first * j->first) * (i->second * j->second);
}
}
printf("%.12lf\n", A / B);
return 0;
}
airis