結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー HAHAHAHAHAHA
提出日時 2015-05-23 12:11:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 281 ms / 5,000 ms
コード長 1,199 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 73,036 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 10:40:52
合計ジャッジ時間 1,486 ms
ジャッジサーバーID
(参考情報)
judge12 / 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,376 KB
testcase_04 AC 9 ms
4,380 KB
testcase_05 AC 281 ms
4,376 KB
testcase_06 AC 48 ms
4,376 KB
testcase_07 AC 48 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<sstream>
#include<cctype>
#include<cmath>
#include<algorithm>
using namespace std;

#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define repp(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define clr(a) memset((a), 0 ,sizeof(a))


typedef pair<int,int> P;
typedef vector<pair<int,string> > pii;
typedef map<string,int> mi;


void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}

double sum;
double cnt;
int a[] = {2,3,5,7,11,13};
int b[] = {4,6,8,9,10,12};
void dfs(int P, int C, double A) {
    if(P > 0) {
        rep(i, 6) dfs(P-1, C, A * a[i]);
    } else if(C > 0) {
        rep(i, 6) dfs(P, C-1, A * b[i]);
    } else {
        sum += A;
        cnt += 1;
    }
}
int main(){
    iostream_init();
    int P, C;
    cin >> P >> C;
    dfs(P, C, 1.0);
    cout << sum / cnt << endl;
    return 0;
}
0