結果

問題 No.1688 Veterinarian
ユーザー TKTYITKTYI
提出日時 2021-09-24 21:44:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 463 ms / 3,000 ms
コード長 1,360 bytes
コンパイル時間 4,023 ms
コンパイル使用メモリ 227,596 KB
実行使用メモリ 111,380 KB
最終ジャッジ日時 2023-09-18 21:03:54
合計ジャッジ時間 5,427 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 6 ms
7,832 KB
testcase_08 AC 463 ms
111,380 KB
testcase_09 AC 433 ms
103,072 KB
testcase_10 AC 22 ms
12,212 KB
testcase_11 AC 26 ms
14,620 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 3 ms
4,388 KB
testcase_14 AC 5 ms
5,144 KB
testcase_15 AC 15 ms
10,080 KB
testcase_16 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef long double ld;
#define FOR(i,l,r) for(ll i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,l,r) for(ll i=r-1;i>=l;i--)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
#define BS(A,x) binary_search(ALL(A),x)
#define LB(A,x) (ll)(lower_bound(ALL(A),x)-A.begin())
#define UB(A,x) (ll)(upper_bound(ALL(A),x)-A.begin())
#define COU(A,x) UB(A,x)-LB(A,x)
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
using mint=modint1000000007;
signed main(){
  ll A,B,C,N;cin>>A>>B>>C>>N;ld DP[A+1][B+1][C+1][N+1];
  REP(i,A+1)REP(j,B+1)REP(k,C+1)REP(n,N+1)DP[i][j][k][n]=0;DP[A][B][C][0]=1;
  REP(n,N){
    REP(i,A+1)REP(j,B+1)REP(k,C+1)if(i+j+k>1){
      DP[i-1][j][k][n+1]+=DP[i][j][k][n]*i*(i-1)/(i+j+k)/(i+j+k-1);
      DP[i][j-1][k][n+1]+=DP[i][j][k][n]*j*(j-1)/(i+j+k)/(i+j+k-1);
      DP[i][j][k-1][n+1]+=DP[i][j][k][n]*k*(k-1)/(i+j+k)/(i+j+k-1);
      DP[i][j][k][n+1]+=DP[i][j][k][n]*(1-(ld)(i*(i-1)+j*(j-1)+k*(k-1))/(i+j+k)/(i+j+k-1));
    }
  }
  ld a=0,b=0,c=0;
  REP(i,A+1)REP(j,B+1)REP(k,C+1){a+=DP[i][j][k][N]*i;b+=DP[i][j][k][N]*j;c+=DP[i][j][k][N]*k;}
  a=A-a;b=B-b;c=C-c;printf("%llf %llf %llf\n",a,b,c);
  return 0;
}
0