Created
December 7, 2024 12:45
-
-
Save lychees/b3a72cbedb02b87f17f7a823f213604f to your computer and use it in GitHub Desktop.
条件概率 + 二项分布
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <lastweapon/number> | |
using namespace lastweapon; | |
const int N = 51, M = 101; | |
DB F[N][N][M][M]; | |
DB f(int a, int b, int c = 0, int d = 0) { | |
if (c == M || d == M) return 0; | |
DB &z = F[a][b][c][d]; | |
if (z == 0) { | |
if (!a || !b) z = 20*(a+b); | |
else { | |
// pa + pb = 1 | |
// p(a|s) = p(as) / p(s) | |
// p(b|s) = p(bs) / p(s) | |
// p(as) = p(s|a) * p(a) | |
// p(bs) = p(s|b) * p(b) | |
// p(as)/p(bs) = p(s|a)p(a)/p(s|b)p(b) | |
DB pa = pow(2.0, d) * a, pb = pow(1.5, c) * b; | |
DB pab = pa + pb; pa = pa / pab; pb = pb / pab; | |
DB pd = pa / 2 + pb / 4, pc = 1 - pd; | |
DB guess = 10*max((2*pa-5*pb), (2*pb-5*pa)) + pa*f(a-1,b) + pb*f(a, b-1); | |
DB toss = pc * f(a, b, c+1, d) + pd * f(a, b, c, d+1) - 1; | |
z = max(guess, toss); | |
} | |
} | |
return z; | |
} | |
int main() { | |
#ifndef ONLINE_JUDGE | |
freopen("in.txt", "r", stdin); | |
//freopen("/Users/minakokojima/Documents/GitHub/ACM-Training/Workspace/out.txt", "w", stdout); | |
#endif | |
int n = 50; | |
printf("%.6f\n", f(50, 50)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment