結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー latte0119latte0119
提出日時 2015-05-22 23:36:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 1,218 bytes
コンパイル時間 1,225 ms
コンパイル使用メモリ 153,404 KB
実行使用メモリ 5,084 KB
最終ジャッジ日時 2023-09-20 10:06:36
合計ジャッジ時間 1,947 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP((i),0,(n))
#define RREP(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rrep(i,n) RREP(i,n,0)
#define each(it,X) for(__typeof((X).begin())  it=(X).begin();it!=(X).end();it++)
#define all(v) ((v).begin(),(v).end())
#define fi first
#define se second
#define pb push_back
typedef pair<int,int>pr;
typedef vector<int>vi;
typedef vector<vi>vvi;
const int INF=1070000000ll;
const int mod=1000000007ll;

int a[]={2,3,5,7,11,13};
int b[]={4,6,8,9,10,12};

signed main(){
    int p,c;cin>>p>>c;

    map<int,int>prev;
    prev[1]=1;

    rep(i,p){
        map<int,int>next;
        each(it,prev){
            rep(j,6){
                next[it->first*a[j]]+=it->second;
            }
        }
        prev=next;
    }

    rep(i,c){
        map<int,int>next;
        each(it,prev){
            rep(j,6){
                next[it->first*b[j]]+=it->second;
            }
        }
        prev=next;
    }


    int d=1;rep(i,p+c)d*=6;

    int ret=0;
    each(it,prev){
        ret+=it->first*it->second;
    }

    cout<<setprecision(10);
    cout<<1.0*ret/d<<endl;
    return 0;
}
0