Test instructions: There are n chat people and M boring people, each time the probability of choice of two people, let them become bored people, ask everyone to become bored people's expectations. ( < Span class= "Mrow" id= "mathjax-span-2" > 1 ≤ n m ≤ )。
Solution: Set F (i) indicates the number of expected times that I have a chat person and turn everyone into boring people. Obviously f (0) = 0, i.e. no change is required. Equation: F (I)=F (I?2)x C 2 i C 2 N+m +F (I?1)xi x ( n + m ? i ) C 2 N+m +F (I)x C 2 N+m? I C 2 N+m +1 .
The answer is f (m)
Code
#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>classtheboredomdivone{ Public:Doublef[ -];DoubleCDoublex) {returnX * (X-1) /2; }DoubleFindintNintm) {memset(F,0,sizeof(f)); f[0] =0; for(inti =1; I <= m; i++) {F[i] = (f[i-2] * C (i) + f[i-1] * I * (n + m-i) + C (n + M))/(c (n + M)-C (n + m-i)); }returnF[M]; }};
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Topcoder SRM 488 DIV1 250 (probabilistic DP)