結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー kakira9618kakira9618
提出日時 2015-05-22 22:40:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 209 ms / 5,000 ms
コード長 1,853 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 90,204 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 09:38:48
合計ジャッジ時間 1,634 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#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;
}
0