結果
| 問題 |
No.574 正多面体サイコロ
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2017-10-15 21:03:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 1,690 bytes |
| コンパイル時間 | 1,308 ms |
| コンパイル使用メモリ | 170,516 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 17:54:39 |
| 合計ジャッジ時間 | 2,070 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#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);
}
tottoripaper