結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー machymachy
提出日時 2015-06-13 11:14:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 1,006 bytes
コンパイル時間 703 ms
コンパイル使用メモリ 77,980 KB
実行使用メモリ 4,688 KB
最終ジャッジ日時 2023-09-20 21:14:47
合計ジャッジ時間 1,560 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;

typedef long long LL;

int main(){
    int v1[] = {2,3,5,7,11,13};
    int v2[] = {4,6,8,9,10,12};
    int P, C;
    cin >> P >> C;
    map<LL,LL> prev;
    map<LL,LL> next;
    prev[1] = 1;
    for(int i = 0; i < P; i++){
        for(int j = 0; j < 6; j++){
            for(auto& p : prev){
                next[p.first * v1[j]] += p.second;
            }
        }
        prev.swap(next);
        next.clear();
    }
    for(int i = 0; i < C; i++){
        for(int j = 0; j < 6; j++){
            for(auto& p : prev){
                next[p.first * v2[j]] += p.second;
            }
        }
        prev.swap(next);
        next.clear();
    }
    LL total = 0;
    for(auto& p : prev){
        total += p.second;
    }
    double exp = 0.0;
    for(auto& p : prev){
        exp += p.first * (double)(p.second) / total;
    }
    cout << setprecision(13) << exp << endl;
    return 0;
}
0