Advertisement
Saleh127

UVA 10375

Nov 22nd, 2020 (edited)
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9.  
  10. ll a,c,d,e,f,i,j,k,l;
  11.  
  12. while(cin>>a>>c>>d>>e)
  13. {
  14.  
  15.  
  16. c=min(c,a-c);
  17. e=min(e,d-e);
  18.  
  19. double ans=1.0;
  20.  
  21. for(i=0; i<c || i<e; i++)
  22. {
  23. if(i<c)
  24. {
  25. ans=ans*(a-i);
  26. ans=ans/(i+1);
  27. }
  28. if(i<e)
  29. {
  30. ans=ans*(i+1);
  31. ans=ans/(d-i);
  32. }
  33.  
  34. }
  35. printf("%.5lf\n",ans);
  36. }
  37. return 0;
  38. }
  39.  
  40. /*
  41. #include <bits/stdc++.h>
  42. using namespace std;
  43. #define ll long long
  44. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  45. int main()
  46. {
  47. ios_base::sync_with_stdio(0);
  48. cin.tie(0);
  49. cout.tie(0);
  50.  
  51. ll p,q,r,s,i,j,k,l;
  52. while(cin>>p>>q>>r>>s)
  53. {
  54. double ans=1.00;
  55. q=min(q,p-q);
  56. s=min(s,r-s);
  57.  
  58. for(i=1; i<=q || i<=s ; i++)
  59. {
  60. if(i<=q)
  61. {
  62. ans=ans*(p-i+1)/i;
  63. }
  64. if(i<=s)
  65. {
  66. ans=ans*i/(r-i+1);
  67. }
  68. }
  69. printf("%.5lf\n",ans);
  70. }
  71.  
  72.  
  73. return 0;
  74. }
  75. */
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement