結果

問題 No.1688 Veterinarian
ユーザー ysystem7ysystem7
提出日時 2021-10-11 16:13:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 97 ms / 3,000 ms
コード長 2,557 bytes
コンパイル時間 3,541 ms
コンパイル使用メモリ 215,532 KB
実行使用メモリ 64,076 KB
最終ジャッジ日時 2023-10-13 21:26:29
合計ジャッジ時間 4,575 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 3 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 4 ms
6,172 KB
testcase_07 AC 4 ms
4,792 KB
testcase_08 AC 97 ms
64,076 KB
testcase_09 AC 93 ms
61,528 KB
testcase_10 AC 15 ms
12,904 KB
testcase_11 AC 12 ms
10,780 KB
testcase_12 AC 3 ms
4,352 KB
testcase_13 AC 5 ms
6,288 KB
testcase_14 AC 4 ms
4,824 KB
testcase_15 AC 9 ms
8,928 KB
testcase_16 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
//#define mod 1000000007
#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

double dp[55][55][55][55];
ll com[55][55];

int main(){
    //オーバーフローは大丈夫ですか??
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c,n;
    cin>>a>>b>>c>>n;
    rep(i,51){
        if(i==0) continue;
        com[i][0]=1;
        com[i][1]=i;
    }
    for(int i=2;i<=50;i++){
        for(int j=2;j<=i;j++){
            com[i][j]=com[i-1][j-1]+com[i-1][j];
        }
    }
    dp[0][0][0][0]=1;
    double A=0,B=0,C=0;
    rep(id,n){
        for(ll i=0;i<=a;i++){
            for(ll j=0;j<=b;j++){
                for(ll k=0;k<=c;k++){
                    ll rem=a+b+c-(i+j+k);
                    if(rem<2) continue;
                    rem=rem*(rem-1)/2;
                    double cur=dp[id][i][j][k];
                    if(a-i>=2) dp[id+1][i+1][j][k]+=(double)cur*(a-i)*(a-i-1)/2/rem;
                    if(b-j>=2) dp[id+1][i][j+1][k]+=(double)cur*(b-j)*(b-j-1)/2/rem;
                    if(c-k>=2) dp[id+1][i][j][k+1]+=(double)cur*(c-k)*(c-k-1)/2/rem;
                    ll x=(a-i)*(b-j)+(b-j)*(c-k)+(a-i)*(c-k);
                    dp[id+1][i][j][k]+=(double)cur*x/rem;
                }
            }
        }
    }
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                double cur=dp[n][i][j][k];
                A+=(double)i*cur;
                B+=(double)j*cur;
                C+=(double)k*cur;
            }
        }
    }
    cout<<FS<<(double)A<<' '<<(double)B<<' '<<(double)C<<endl;
}
0