結果
問題 | No.574 正多面体サイコロ |
ユーザー |
![]() |
提出日時 | 2017-10-07 03:39:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,295 bytes |
コンパイル時間 | 716 ms |
コンパイル使用メモリ | 91,600 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 03:29:16 |
合計ジャッジ時間 | 1,523 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <cstdio>#include <cassert>#include <cmath>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <map>#include <set>#include <functional>#include <stack>#include <queue>#include <tuple>#define getchar getchar_unlocked#define putchar putchar_unlocked#define _rep(_1, _2, _3, _4, name, ...) name#define rep2(i, n) rep3(i, 0, n)#define rep3(i, a, b) rep4(i, a, b, 1)#define rep4(i, a, b, c) for (int i = int(a); i < int(b); i += int(c))#define rep(...) _rep(__VA_ARGS__, rep4, rep3, rep2, _)(__VA_ARGS__)using namespace std;using i64 = long long;using u8 = unsigned char;using u32 = unsigned;using u64 = unsigned long long;using f80 = long double;void solve() {const int F_MAX = 20, N_MAX = 100;int F, N, K;while (~scanf("%d %d %d", &F, &N, &K)) {vector<double> facts(N + 1, 1.0);rep(i, 1, N + 1) facts[i] = facts[i - 1] * i;double ans = 0.0;rep(j, 1, F) {double p = 1.0, q = pow(F - j, N);rep(i, K) ans += p / facts[i] * q / facts[N - i], p *= j, q /= F - j;}printf("%.15f\n", F - ans / pow(F, N) * facts[N]);}}int main() {clock_t beg = clock();solve();clock_t end = clock();fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC);return 0;}