結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー goodbatongoodbaton
提出日時 2015-09-21 13:18:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 218 ms / 5,000 ms
コード長 925 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 71,068 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 14:09:32
合計ジャッジ時間 1,790 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000 //(int)1e9
#define LLINF 2000000000000000000 //(ll)2e18
#define PI  3.1415926536

#define SIZE 100000

int dice1[] = {2,3,5,7,11,13};
int dice2[] = {4,6,8,9,10,12};
int p,c;
ll sum=0;
ll cc = 0;

void dfs(int h,ll calc){
    
    if(h==p+c){
        sum += calc;
        cc ++;
        return;
    }
    
    if(h < p){
        for(int i=0;i<6;i++){
            dfs(h+1,calc*dice1[i]);
        }
    }else{
        for(int i=0;i<6;i++){
            dfs(h+1,calc*dice2[i]);
        }
    }
    
}

int main(){
    scanf("%d%d",&p,&c);
    
    dfs(0,1);
    
    
    printf("%.15lf",(double)sum/cc);
    
    return 0;
}
0