結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-11-08 20:50:51
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 608 bytes
コンパイル時間 5,951 ms
コンパイル使用メモリ 311,576 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-08 20:50:58
合計ジャッジ時間 6,846 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;

vector<int> prime_dice={2,3,5,7,11,13};
vector<int> comp_dice={4,6,8,9,10,12};

ll calc(int P,int C,ll pro){
    if(P==0&&C==0){
        return pro;
    }
    ll ret=0;
    if(P==0){
        for(int i:comp_dice){
            ret+=calc(P,C-1,pro*i);
        }
    }
    else{
        for(int i:prime_dice){
            ret+=calc(P-1,C,pro*i);
        }
    }
    return ret;
}

int main(){
    int P,C;
    cin>>P>>C;
    cout<<fixed<<setprecision(20);
    cout<<calc(P,C,1)/pow(6,P+C)<<endl;
}
0