結果

問題 No.574 正多面体サイコロ
ユーザー tottoripapertottoripaper
提出日時 2017-10-15 21:03:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 1,690 bytes
コンパイル時間 1,615 ms
コンパイル使用メモリ 168,004 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 04:41:53
合計ジャッジ時間 3,097 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 12 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 13 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 33 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

#include <iostream>
#include <limits>
#include <vector>

template <typename T>
struct Combination{
    std::vector<T> fact;

    Combination() = default;
    Combination(int max_n) {
        fact = std::vector<T>(max_n);     
    }
    Combination(Combination const &) = default;
    Combination(Combination&&) = default;
    Combination& operator=(Combination const &) = default;
    Combination& operator=(Combination&&) = default;
    
    T nCk(int n, int k){
        if(n < k){return 0;}
        T res = 1;
        for(int i=n-k+1;i<=n;++i){
            res *= i;
        }
        for(int i=1;i<=k;++i){
            res /= i;
        }

        return res;
    }
};

Combination<double> combination(50);

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int F, N, K;
    std::cin >> F >> N >> K;

    double res = 0.0;
    for(int i=1;i<=F;++i){
        for(int x=0;x<=K-1;++x){
            for(int y=0;y<=N-K;++y){
                int s = K - 1 - x,
                    t = x + y + 1,
                    u = N - K - y,
                    a = F - i,
                    b = i - 1;
                double v = 1. *  i * combination.nCk(N, t) * pow(1. * a / F, s) * combination.nCk(N - t, u) * pow(1. / F, t) * pow(1. * b / F, u);
                res += v;
            }
        }
    }

    printf("%.10f\n", res);
}
0