結果
問題 |
No.574 正多面体サイコロ
|
ユーザー |
![]() |
提出日時 | 2017-10-07 15:07:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,306 bytes |
コンパイル時間 | 788 ms |
コンパイル使用メモリ | 92,856 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-17 04:27:22 |
合計ジャッジ時間 | 1,578 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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() { int F, N, K; while (~scanf("%d %d %d", &F, &N, &K)) { vector<double> curr(F), pows(F); rep(i, F) curr[i] = pows[i] = pow(i + 1, N); double binom = 1.0; rep(k, K - 1) { binom = binom * (N - k) / (k + 1); rep(i, F) curr[i] += binom * (pows[i] *= double(F - 1 - i) / (i + 1)); } double ans = 0.0; rep(i, F) ans += curr[i]; printf("%.15f\n", F + 1 - ans / pow(F, 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; }