QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#380854#2428. Comma Sprinklerckiseki#WA 0ms3840kbC++202.3kb2024-04-07 13:34:082024-04-07 13:34:09

Judging History

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

  • [2024-04-07 13:34:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-04-07 13:34:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
#include <experimental/iterator>
void orange_(auto s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

using llf = long double;

const int maxn = 505;

llf g[maxn][maxn][maxn];
llf fac[maxn * 2];

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);

  int n, d, r;
  cin >> n >> d >> r;

  fac[0] = 1;
  for (int i = 1; i < maxn; i++)
    fac[i] = fac[i - 1] * i;
  debug(fac[maxn - 1]);

  g[0][0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= d; j++) {
      for (int k = 0; k <= d; k++) {
        for (int t = 0; t <= i && j * t <= k; t++) {
          g[i][j][k] += g[i-t][j-1][k - j*t] / fac[t];
        }
      }
    }
  }
  
  llf sum = 0;

  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= d; j++) {
      for (int k = 0; k <= d - i * j; k++) {
        sum += min(i, r) * g[i][d][k] * g[n-i][j-1][d - i * j - k];
      }
      orange(g[i][j], g[i][j] + 10);
    }
  }

  debug(sum);

  sum *= fac[n-1];
  sum *= fac[n];
  sum *= fac[d];
  sum /= fac[n+d-1];

  sum += n;

  cout << fixed << setprecision(20);
  cout << sum << '\n';

  return 0;
}

/*

   2 3 1
(fac[maxn - 1]) = (7.77944e+1144)
[ g[i][j], g[i][j] + 10 ] = [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ g[i][j], g[i][j] + 10 ] = [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ g[i][j], g[i][j] + 10 ] = [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ g[i][j], g[i][j] + 10 ] = [ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ g[i][j], g[i][j] + 10 ] = [ 0, 1, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ g[i][j], g[i][j] + 10 ] = [ 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 ]
[ g[i][j], g[i][j] + 10 ] = [ 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0 ]
[ g[i][j], g[i][j] + 10 ] = [ 0, 0, 0.5, 1, 0, 0, 0, 0, 0, 0 ]
[ g[i][j], g[i][j] + 10 ] = [ 0, 0, 0.5, 1, 0, 0, 0, 0, 0, 0 ]
(sum) = (0)
2.00000000000000000000
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb