Submission #18350528


Source Code Expand

/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vvd= vector<vd>;
using vvvd= vector<vvd>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

/* its a dp.
 * dp[a][b][c]= prob that that much coins are in the bag after some move.
 */
const int N=100;
void solve() {
    cini(a);
    cini(b);
    cini(c);

    const int sum=a+b+c;

    vvvd dp(N+1, vvd(N+1, vd(N+1)));
    dp[a][b][c]=1.0;

    for(int aa=a; aa<=99; aa++) {
        for(int bb=b; bb<=99; bb++)  {
            for(int cc=c; cc<=99; cc++) {
                dp[aa+1][bb][cc]+=(dp[aa][bb][cc]*aa)/(aa+bb+cc);
                dp[aa][bb+1][cc]+=(dp[aa][bb][cc]*bb)/(aa+bb+cc);
                dp[aa][bb][cc+1]+=(dp[aa][bb][cc]*cc)/(aa+bb+cc);
            }
        }
    }

/* collect the endstates */
    vd ans(300);
    for(int i=0; i<N; i++)  {
        for(int j=0; j<N; j++) {
            if(i>=a && j>=b)
                ans[i+j+100]+=dp[i][j][100];
            if(i>=a && j>=c)
                ans[i+j+100]+=dp[i][100][j];
            if(i>=b && j>=c)
                ans[i+j+100]+=dp[100][i][j];
        }
    }

    long double aa=0;
    for(size_t i=sum; i<ans.size(); i++)
        aa+=ans[i]*(i-sum);


    cout<<aa<<endl;

}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS

Submission Info

Submission Time
Task D - increment of coins
User dush1729
Language C++ (GCC 9.2.1)
Score 400
Code Size 2153 Byte
Status AC
Exec Time 31 ms
Memory 11996 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 24
Set Name Test Cases
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
Case Name Status Exec Time Memory
hand_01.txt AC 31 ms 11912 KiB
hand_02.txt AC 16 ms 11908 KiB
hand_03.txt AC 21 ms 11928 KiB
hand_04.txt AC 12 ms 11928 KiB
hand_05.txt AC 17 ms 11948 KiB
random_01.txt AC 17 ms 11904 KiB
random_02.txt AC 14 ms 11908 KiB
random_03.txt AC 12 ms 11928 KiB
random_04.txt AC 16 ms 11864 KiB
random_05.txt AC 15 ms 11928 KiB
random_06.txt AC 13 ms 11908 KiB
random_07.txt AC 21 ms 11996 KiB
random_08.txt AC 16 ms 11916 KiB
random_09.txt AC 13 ms 11904 KiB
random_10.txt AC 17 ms 11908 KiB
random_11.txt AC 14 ms 11972 KiB
random_12.txt AC 16 ms 11900 KiB
random_13.txt AC 15 ms 11916 KiB
random_14.txt AC 14 ms 11892 KiB
random_15.txt AC 15 ms 11908 KiB
sample_01.txt AC 13 ms 11920 KiB
sample_02.txt AC 18 ms 11916 KiB
sample_03.txt AC 21 ms 11976 KiB
sample_04.txt AC 13 ms 11948 KiB