fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. class TestProctoring
  6. {
  7. public:
  8. double expectedTime (vector <int> p, vector <int> q)
  9. {
  10. int n = (int) (p.size ());
  11. int m = 1 << n;
  12. vector <double> w (n);
  13. for (int i = 0; i < n; i++)
  14. {
  15. w[i] = p[i];
  16. w[i] /= q[i];
  17. }
  18. double res = 0.0;
  19. for (int s = 1; s < m; s++)
  20. {
  21. double v = 0.0;
  22. double sign = -1.0;
  23. for (int i = 0; i < n; i++)
  24. {
  25. if (s & (1 << i))
  26. {
  27. v = v + w[i] - v * w[i];
  28. sign *= -1.0;
  29. }
  30. }
  31. res += sign * 1.0 / v;
  32. }
  33. return res;
  34. }
  35. };
  36.  
  37. int main ()
  38. {
  39. TestProctoring a;
  40. vector <int> t0 = { 2, 3, 5, 7, 11, 13, 17};
  41. vector <int> t1 = { 3, 5, 7, 11, 13, 17, 19};
  42. printf ("%.20f\n", a.expectedTime (t0, t1));
  43. return 0;
  44. }
  45.  
Success #stdin #stdout 0s 4456KB
stdin
Standard input is empty
stdout
2.62994450659242495760