提出 #18330299
ソースコード 拡げる
/**
* 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<long 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
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - increment of coins |
| ユーザ | spookywooky |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 400 |
| コード長 | 2164 Byte |
| 結果 | AC |
| 実行時間 | 37 ms |
| メモリ | 20232 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 | 35 ms | 20116 KiB |
| hand_02.txt | AC | 25 ms | 20172 KiB |
| hand_03.txt | AC | 34 ms | 20120 KiB |
| hand_04.txt | AC | 17 ms | 20116 KiB |
| hand_05.txt | AC | 16 ms | 20116 KiB |
| random_01.txt | AC | 24 ms | 20208 KiB |
| random_02.txt | AC | 20 ms | 20232 KiB |
| random_03.txt | AC | 16 ms | 20200 KiB |
| random_04.txt | AC | 17 ms | 20136 KiB |
| random_05.txt | AC | 17 ms | 20132 KiB |
| random_06.txt | AC | 20 ms | 20120 KiB |
| random_07.txt | AC | 19 ms | 20124 KiB |
| random_08.txt | AC | 27 ms | 20140 KiB |
| random_09.txt | AC | 18 ms | 20132 KiB |
| random_10.txt | AC | 18 ms | 20132 KiB |
| random_11.txt | AC | 20 ms | 20120 KiB |
| random_12.txt | AC | 20 ms | 20136 KiB |
| random_13.txt | AC | 18 ms | 20144 KiB |
| random_14.txt | AC | 17 ms | 20128 KiB |
| random_15.txt | AC | 21 ms | 20140 KiB |
| sample_01.txt | AC | 22 ms | 20116 KiB |
| sample_02.txt | AC | 17 ms | 20116 KiB |
| sample_03.txt | AC | 37 ms | 20144 KiB |
| sample_04.txt | AC | 19 ms | 20132 KiB |