QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#599728#2430. Gem IslandXiaohubaAC ✓61ms9904kbC++233.0kb2024-09-29 10:02:322024-09-29 10:02:33

Judging History

你现在查看的是最新测评结果

  • [2024-09-29 10:02:33]
  • 评测
  • 测评结果:AC
  • 用时:61ms
  • 内存:9904kb
  • [2024-09-29 10:02:32]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

// #define LOCK_GETCHAR
// #define USE_INT_128

#if __cplusplus < 201400
#warning "Please use c++14 or higher."
#define CONSTEXPR_FUNC
#define ENABLE_IF_INT
#else
#define CONSTEXPR_FUNC constexpr
#define ENABLE_IF_INT , enable_if_t<_is_integer<T>, int> = 0
template <class T> constexpr bool _is_integer = numeric_limits<T>::is_integer;
template <> constexpr bool _is_integer<bool> = false;
template <> constexpr bool _is_integer<char> = false;
#ifdef USE_INT_128
template <> constexpr bool _is_integer<__int128> = true;
template <> constexpr bool _is_integer<__uint128_t> = true;
#endif
#endif

#if !defined(_WIN32) && !defined(LOCK_GETCHAR)
#define getchar getchar_unlocked
#endif

#define il inline
#define mkp make_pair
#define fi first
#define se second
#define _loop_i_t(j, k) make_signed_t<decltype((j) - (k))>
#define For(i, j, k) for (_loop_i_t(j, k) i = (j); i <= (k); ++i) // NOLINT
#define ForDown(i, j, k)                                                       \
  for (_loop_i_t(j, k) i = (j); i >= decltype(i)(k); --i) // NOLINT
#define eb emplace_back
#ifndef ONLINE_JUDGE
#define FileIO(filename)                                                       \
  freopen(filename ".in", "r", stdin);                                         \
  freopen(filename ".out", "w", stdout)
#else
#define FileIO(filename) void(0)
#endif

using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using db = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef USE_INT_128
using lll = __int128_t;
using ulll = __uint128_t;
#endif

// clang-format off
CONSTEXPR_FUNC il ll qpow(ll x, ull y, ll mod){ ll ans = 1; x %= mod; while (y) { if (y & 1) (ans *= x) %= mod; (x *= x) %= mod; y >>= 1; } return ans; }
template<typename T> CONSTEXPR_FUNC il void cmin(T & x, const T &y){ x = min(x, y); }
template<typename T> CONSTEXPR_FUNC il void cmax(T & x, const T &y){ x = max(x, y); }
template<typename T ENABLE_IF_INT> il void read(T &x){ x = 0; int f = 1; int c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } x *= f; }
template<typename T, typename ... Args> il void read(T &x, Args &... y){ read(x), read(y...); }
// clang-format on

// File head end

namespace {
constexpr ll MAXN = 505;
int n, d, r;
db f[MAXN][MAXN], g[MAXN][MAXN], C[MAXN][MAXN];
il void Main() {
  read(n, d, r);
  C[0][0] = 1;
  For(i, 1, 500) {
    C[i][0] = C[i][i] = 1;
    For(j, 1, i - 1) C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
  }
  f[0][n] = 1, g[0][n] = 0;
  For(i, 0, d - 1) For(j, 1, n) For(k, 1, min(d - i, j)) {
    f[i + k][k] += f[i][j] * C[j][k];
    g[i + k][k] += (g[i][j] + min(k, r) * f[i][j]) * C[j][k];
  }
  db F = 0, G = 0;
  For(i, 1, n) F += f[d][i], G += g[d][i];
  cout << fixed << setprecision(7) << G / F + r << '\n';
}
} // namespace

signed main() { return Main(), 0; }

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 9420kb

Test #2:

score: 0
Accepted
time: 1ms
memory: 8064kb

Test #3:

score: 0
Accepted
time: 1ms
memory: 8592kb

Test #4:

score: 0
Accepted
time: 1ms
memory: 8120kb

Test #5:

score: 0
Accepted
time: 1ms
memory: 8236kb

Test #6:

score: 0
Accepted
time: 1ms
memory: 8212kb

Test #7:

score: 0
Accepted
time: 0ms
memory: 8672kb

Test #8:

score: 0
Accepted
time: 0ms
memory: 9632kb

Test #9:

score: 0
Accepted
time: 2ms
memory: 9760kb

Test #10:

score: 0
Accepted
time: 0ms
memory: 9768kb

Test #11:

score: 0
Accepted
time: 0ms
memory: 8260kb

Test #12:

score: 0
Accepted
time: 1ms
memory: 9000kb

Test #13:

score: 0
Accepted
time: 1ms
memory: 8924kb

Test #14:

score: 0
Accepted
time: 1ms
memory: 9124kb

Test #15:

score: 0
Accepted
time: 1ms
memory: 8672kb

Test #16:

score: 0
Accepted
time: 1ms
memory: 7824kb

Test #17:

score: 0
Accepted
time: 0ms
memory: 8320kb

Test #18:

score: 0
Accepted
time: 1ms
memory: 8200kb

Test #19:

score: 0
Accepted
time: 2ms
memory: 9416kb

Test #20:

score: 0
Accepted
time: 0ms
memory: 9852kb

Test #21:

score: 0
Accepted
time: 2ms
memory: 9780kb

Test #22:

score: 0
Accepted
time: 0ms
memory: 8084kb

Test #23:

score: 0
Accepted
time: 0ms
memory: 9444kb

Test #24:

score: 0
Accepted
time: 0ms
memory: 8616kb

Test #25:

score: 0
Accepted
time: 2ms
memory: 9588kb

Test #26:

score: 0
Accepted
time: 1ms
memory: 8188kb

Test #27:

score: 0
Accepted
time: 1ms
memory: 9004kb

Test #28:

score: 0
Accepted
time: 2ms
memory: 8348kb

Test #29:

score: 0
Accepted
time: 0ms
memory: 9728kb

Test #30:

score: 0
Accepted
time: 1ms
memory: 8856kb

Test #31:

score: 0
Accepted
time: 1ms
memory: 8996kb

Test #32:

score: 0
Accepted
time: 2ms
memory: 9504kb

Test #33:

score: 0
Accepted
time: 1ms
memory: 7836kb

Test #34:

score: 0
Accepted
time: 1ms
memory: 8476kb

Test #35:

score: 0
Accepted
time: 0ms
memory: 9424kb

Test #36:

score: 0
Accepted
time: 0ms
memory: 9084kb

Test #37:

score: 0
Accepted
time: 2ms
memory: 9428kb

Test #38:

score: 0
Accepted
time: 0ms
memory: 9112kb

Test #39:

score: 0
Accepted
time: 0ms
memory: 9676kb

Test #40:

score: 0
Accepted
time: 0ms
memory: 9036kb

Test #41:

score: 0
Accepted
time: 1ms
memory: 8916kb

Test #42:

score: 0
Accepted
time: 1ms
memory: 9112kb

Test #43:

score: 0
Accepted
time: 0ms
memory: 9784kb

Test #44:

score: 0
Accepted
time: 0ms
memory: 8976kb

Test #45:

score: 0
Accepted
time: 0ms
memory: 8312kb

Test #46:

score: 0
Accepted
time: 0ms
memory: 8872kb

Test #47:

score: 0
Accepted
time: 1ms
memory: 8656kb

Test #48:

score: 0
Accepted
time: 2ms
memory: 8000kb

Test #49:

score: 0
Accepted
time: 2ms
memory: 9852kb

Test #50:

score: 0
Accepted
time: 0ms
memory: 9848kb

Test #51:

score: 0
Accepted
time: 0ms
memory: 9788kb

Test #52:

score: 0
Accepted
time: 2ms
memory: 9824kb

Test #53:

score: 0
Accepted
time: 2ms
memory: 9528kb

Test #54:

score: 0
Accepted
time: 0ms
memory: 9756kb

Test #55:

score: 0
Accepted
time: 3ms
memory: 9604kb

Test #56:

score: 0
Accepted
time: 2ms
memory: 9640kb

Test #57:

score: 0
Accepted
time: 0ms
memory: 9324kb

Test #58:

score: 0
Accepted
time: 0ms
memory: 8844kb

Test #59:

score: 0
Accepted
time: 2ms
memory: 8172kb

Test #60:

score: 0
Accepted
time: 2ms
memory: 8212kb

Test #61:

score: 0
Accepted
time: 0ms
memory: 8976kb

Test #62:

score: 0
Accepted
time: 1ms
memory: 8172kb

Test #63:

score: 0
Accepted
time: 1ms
memory: 9024kb

Test #64:

score: 0
Accepted
time: 0ms
memory: 8568kb

Test #65:

score: 0
Accepted
time: 20ms
memory: 9648kb

Test #66:

score: 0
Accepted
time: 8ms
memory: 8952kb

Test #67:

score: 0
Accepted
time: 2ms
memory: 9040kb

Test #68:

score: 0
Accepted
time: 0ms
memory: 9220kb

Test #69:

score: 0
Accepted
time: 1ms
memory: 8388kb

Test #70:

score: 0
Accepted
time: 50ms
memory: 9520kb

Test #71:

score: 0
Accepted
time: 56ms
memory: 9808kb

Test #72:

score: 0
Accepted
time: 57ms
memory: 9864kb

Test #73:

score: 0
Accepted
time: 0ms
memory: 8744kb

Test #74:

score: 0
Accepted
time: 1ms
memory: 9620kb

Test #75:

score: 0
Accepted
time: 1ms
memory: 8692kb

Test #76:

score: 0
Accepted
time: 4ms
memory: 9244kb

Test #77:

score: 0
Accepted
time: 6ms
memory: 9584kb

Test #78:

score: 0
Accepted
time: 6ms
memory: 9096kb

Test #79:

score: 0
Accepted
time: 5ms
memory: 8404kb

Test #80:

score: 0
Accepted
time: 31ms
memory: 9104kb

Test #81:

score: 0
Accepted
time: 61ms
memory: 9860kb

Test #82:

score: 0
Accepted
time: 56ms
memory: 9760kb

Test #83:

score: 0
Accepted
time: 61ms
memory: 9904kb

Test #84:

score: 0
Accepted
time: 60ms
memory: 9788kb