Advertisement
Saleh127

UVA 10491

Mar 17th, 2021
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. double cow,car,show,total,goru,gari,gari1,gari2,ans;
  11.  
  12. while(cin>>cow>>car>>show)
  13. {
  14.  
  15. /// two ways to get a car:
  16. /// either pick a cow first; ->goru
  17. /// then switch to a car; ->gari
  18. /// or pick a car first; ->gari1
  19. /// and then switch to another car; ->gari2
  20.  
  21. total=car+cow;
  22.  
  23. goru=cow/total; ///pick a cow first
  24.  
  25. gari=car/total; ///switch to a car;
  26.  
  27. gari1=car/(total-1.0-show); ///pick a car first;
  28.  
  29. gari2=(car-1.0)/(total-1.0-show); ///switch to another car
  30.  
  31. ans=goru*gari1+gari*gari2;
  32.  
  33. cout<<fixed<<setprecision(5)<<ans<<endl;
  34.  
  35. }
  36.  
  37.  
  38. return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement