fork(3) download
  1. #include <bits/stdc++.h>
  2. #define EPS double(1e-10)
  3. using namespace std;
  4.  
  5. double factorial(double n)
  6. {
  7. if(n==0)
  8. return 1;
  9. if(n==1)
  10. return 1;
  11. return n*factorial(n-1);
  12. }
  13.  
  14. double combination(double n,double k)
  15. {
  16. double rpta = factorial(n)/(factorial(k)*factorial(n-k));
  17. // cout << rpta << "\n";
  18. return double(rpta);
  19. }
  20.  
  21.  
  22. int main()
  23. {
  24. int n;cin >> n;
  25. for(int i = 0 ; i < n ; ++i)
  26. {
  27. double r,s,x,y,w; cin >> r >> s >> x >> y >> w;
  28. double d = s-r+1;
  29. double prob = d/s;
  30. // cout << prob << "\n";
  31. double rprob = prob;
  32. for(int j = 0 ; j < int(x)-1 ; ++j)
  33. {
  34. rprob*=prob;
  35. }
  36. // cout << rprob << "\n";
  37. double rrprob = double(combination(y,x) * w * rprob);
  38. cout << rrprob << "\n";
  39. // cout << rrprob << "\n";
  40. if(rrprob > double(1) )
  41. {
  42. cout << "yes";
  43. }
  44. else
  45. cout << "no";
  46. cout << "\n";
  47. }
  48. return 0;
  49. }
  50.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Standard output is empty