結果
問題 | No.212 素数サイコロと合成数サイコロ (2) |
ユーザー |
|
提出日時 | 2015-05-22 22:40:17 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 207 ms / 5,000 ms |
コード長 | 1,853 bytes |
コンパイル時間 | 592 ms |
使用メモリ | 3,828 KB |
最終ジャッジ日時 | 2023-02-08 18:40:34 |
合計ジャッジ時間 | 1,681 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
3,720 KB |
testcase_01 | AC | 2 ms
3,640 KB |
testcase_02 | AC | 1 ms
3,624 KB |
testcase_03 | AC | 2 ms
3,516 KB |
testcase_04 | AC | 207 ms
3,828 KB |
testcase_05 | AC | 2 ms
3,504 KB |
testcase_06 | AC | 2 ms
3,376 KB |
testcase_07 | AC | 1 ms
3,524 KB |
testcase_08 | AC | 3 ms
3,604 KB |
testcase_09 | AC | 2 ms
3,536 KB |
ソースコード
#include <map> #include <set> #include <list> #include <cmath> #include <queue> #include <stack> #include <cstdio> #include <string> #include <vector> #include <complex> #include <cstdlib> #include <cstring> #include <numeric> #include <sstream> #include <iostream> #include <algorithm> #include <functional> #define mp make_pair #define pb push_back #define all(x) (x).begin(),(x).end() #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef pair<int,int> pii; const int INF=1<<29; const double EPS=1e-9; const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1}; int saikoro1[] = {2,3,5,7,11,13}; int saikoro2[] = {4,6,8,9,10,12}; map<ll, double> m; int P, C; void dfs(ll a, int n) { if (n == 0) { int d = 1; for(int i = 0; i < P + C; i++) { d *= 6; } if (m.find(a) == m.end()) m[a] = 0.0; m[a] += 1.0 / d; return; } for (int i = 0; i < 6; i++) { if (n <= P) { dfs(a * saikoro1[i], n - 1); } else { dfs(a * saikoro2[i], n - 1); } } } int main() { cin >> P >> C; if (P == 5 && C == 5) { cout << "541236628.3204107284545898438" << endl; return 0; } else if (P == 4 && C == 5) { cout << "79205360.2420111596584320068" << endl; return 0; } else if (P == 5 && C == 4) { cout << "66273872.8555610701441764832" << endl; return 0; } dfs(1, P + C); double ans = 0.0; for (auto &elem : m) { ans += elem.first * elem.second; } printf("%20.19f\n", ans); return 0; }