This question... No
Orz this answer P33 starts 2333
1 /************************************** * *********************** 2 Problem: 2318 3 User: rausen 4 Language: C ++ 5 results: Accepted 6 Time: 0 MS 7 Memory: 808 kb 8 ************************************* * *************************/9 10 # include <cstdio> 11 # include <cmath> 12 # include <algorithm> 13 14 using namespace std; 15 typedef double lf; 16 const int N = 105; 17 int T, n; 18 lf p, q, k; 19 lf p1, p2, p3, p4; 20 lf p5, p6, p7, p8; 21 lf f [N], s [N]; 22 23 int main () {24 scanf ("% d", & T ); 25 int I; 26 while (T --) {27 scanf ("% d % lf", & n, & p, & q ); 28 f [0] = 0, s [0] = 1; 29 n = min (100, n); 30 k = 1-(1-p) * (1-q); 31 p1 = p/k, p2 = (1-p) * q/k; 32 p3 = (1-q) * p/k, p4 = q/k; 33 k = 1-p * q; 34 p5 = (1-p)/k, p6 = (1-q) * p/k; 35 p7 = q * (1-p)/k, p8 = (1-q)/k; 36 for (I = 1; I <= n; ++ I) 37 if (f [I-1] <s [I-1]) {38 f [I] = p1 * s [I-1] + p2 * f [I-1]; 39 s [I] = p3 * s [I-1] + p4 * f [I-1]; 40} else {41 f [I] = p5 * s [I-1] + p6 * f [I-1]; 42 s [I] = p7 * s [I-1] + p8 * f [I-1]; 43} 44 printf ("%. 6lf \ n ", f [n]); 45} 46 return 0; 47}View Code
BZOJ2318 Spoj4060 game with probability Problem