Ankit_132

E

Nov 29th, 2023
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7.  
  8. int main()
  9. {
  10.     _test
  11.     {
  12.         double b, m, n, k;
  13.         cin>>b>>m>>n>>k;
  14.  
  15.         if(b == 1)
  16.         {
  17.             cout<<m<<"\n";
  18.             continue;
  19.         }
  20.  
  21.         double r = (m*1.0)/(m+n);
  22.  
  23.         cout<<fixed<<setprecision(10);
  24.  
  25.         if(k == b)  cout<<m+r*(k-1)<<"\n";
  26.         else        cout<<m-r<<"\n";
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment