提出 #18344256


ソースコード 拡げる

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

long double dp[101][101][101];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i <= 100; i++)
    for (int j = 0; j <= 100; j++)
      for (int k = 0; k <= 100; k++)
        dp[i][j][k] = -1.0;
  function<long double(int, int, int)> solve = [&](int x, int y, int z) -> long double {
    if (x == 100 || y == 100 || z == 100)
      return (x - a) + (y - b) + (z - c);
    if (dp[x][y][z] != -1.0) {
      return dp[x][y][z];
    }
    long double res = ((long double) x / (long double) (x + y + z)) * solve(x + 1, y, z);
    res += ((long double) y / (long double) (x + y + z)) * solve(x, y + 1, z);
    res += ((long double) z / (long double) (x + y + z)) * solve(x, y, z + 1);
    return dp[x][y][z] = res;
  };
  long double ans = solve(a, b, c);
  cout << fixed << setprecision(12) << ans << '\n';
  return 0;
}

提出情報

提出日時
問題 D - increment of coins
ユーザ madlogic
言語 C++ (GCC 9.2.1)
得点 400
コード長 954 Byte
結果 AC
実行時間 55 ms
メモリ 19880 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 4
AC × 24
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 53 ms 19732 KiB
hand_02.txt AC 35 ms 19792 KiB
hand_03.txt AC 55 ms 19736 KiB
hand_04.txt AC 21 ms 19748 KiB
hand_05.txt AC 17 ms 19728 KiB
random_01.txt AC 28 ms 19740 KiB
random_02.txt AC 21 ms 19744 KiB
random_03.txt AC 19 ms 19712 KiB
random_04.txt AC 24 ms 19836 KiB
random_05.txt AC 21 ms 19696 KiB
random_06.txt AC 26 ms 19744 KiB
random_07.txt AC 25 ms 19740 KiB
random_08.txt AC 39 ms 19868 KiB
random_09.txt AC 22 ms 19732 KiB
random_10.txt AC 19 ms 19752 KiB
random_11.txt AC 19 ms 19748 KiB
random_12.txt AC 19 ms 19880 KiB
random_13.txt AC 21 ms 19716 KiB
random_14.txt AC 22 ms 19828 KiB
random_15.txt AC 23 ms 19880 KiB
sample_01.txt AC 18 ms 19812 KiB
sample_02.txt AC 19 ms 19816 KiB
sample_03.txt AC 52 ms 19716 KiB
sample_04.txt AC 31 ms 19736 KiB