Submission #18349029
Source Code Expand
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
#define N 101
ld dp[N][N][N];
ll a,b,c;
ld get(ll c1, ll c2, ll c3)
{
if(c1<0 || c2<0 || c3<0 || c1 == 100 || c2 == 100 || c3 == 100)
return 0;
if(dp[c1][c2][c3] != (ld)-1)
return dp[c1][c2][c3];
if(c1<a || c2<b || c3<c)
return 0;
//cout<<"at "<<c1<<" , "<<c2<<" , "<<c3<<"\n";
if(a == 0 && c1>0)
return 0;
if(b == 0 && c2>0)
return 0;
if(c == 0 && c3>0)
return 0;
//cout<<"at "<<c1<<" , "<<c2<<" , "<<c3<<"\n";
/*if(c1+c2+c3 == 1)
cout<<"At "<<c1<<" , "<<c2<<" , "<<c3<<'\n';*/
ld ans = 0;
ld tot = (c1+c2+c3);
//cout<<"tot = "<<tot<<'\n';
if(a>0)
ans+=((c1)/tot)*(get(c1+1,c2,c3));
if(b>0)
ans+=((c2)/tot)*(get(c1,c2+1,c3));
if(c>0)
ans+=((c3)/tot)*(get(c1,c2,c3+1));
ans++;
//cout<<"at "<<c1<<" , "<<c2<<" , "<<c3<<" "<<ans<<"\n";
return dp[c1][c2][c3] = ans;
}
int main()
{
FAST/**/
cin>>a>>b>>c;
rep(N)
repi(j,N)
repi(k,N)
dp[i][j][k] = -1;
ld ans = get(a,b,c);
cout<<fixed<<setprecision(12)<<ans<<'\n';
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - increment of coins |
| User |
rohit_goyal |
| Language |
C++ (GCC 9.2.1) |
| Score |
400 |
| Code Size |
2119 Byte |
| Status |
AC |
| Exec Time |
55 ms |
| Memory |
19856 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
400 / 400 |
| Status |
|
|
| 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 |
18 ms |
19744 KiB |
| hand_02.txt |
AC |
20 ms |
19736 KiB |
| hand_03.txt |
AC |
55 ms |
19772 KiB |
| hand_04.txt |
AC |
19 ms |
19740 KiB |
| hand_05.txt |
AC |
22 ms |
19856 KiB |
| random_01.txt |
AC |
24 ms |
19820 KiB |
| random_02.txt |
AC |
17 ms |
19736 KiB |
| random_03.txt |
AC |
25 ms |
19812 KiB |
| random_04.txt |
AC |
32 ms |
19812 KiB |
| random_05.txt |
AC |
20 ms |
19728 KiB |
| random_06.txt |
AC |
34 ms |
19816 KiB |
| random_07.txt |
AC |
29 ms |
19780 KiB |
| random_08.txt |
AC |
41 ms |
19828 KiB |
| random_09.txt |
AC |
23 ms |
19748 KiB |
| random_10.txt |
AC |
21 ms |
19812 KiB |
| random_11.txt |
AC |
21 ms |
19724 KiB |
| random_12.txt |
AC |
23 ms |
19828 KiB |
| random_13.txt |
AC |
24 ms |
19744 KiB |
| random_14.txt |
AC |
24 ms |
19780 KiB |
| random_15.txt |
AC |
29 ms |
19828 KiB |
| sample_01.txt |
AC |
17 ms |
19728 KiB |
| sample_02.txt |
AC |
19 ms |
19728 KiB |
| sample_03.txt |
AC |
19 ms |
19728 KiB |
| sample_04.txt |
AC |
22 ms |
19784 KiB |