Advertisement
Saleh127

Light OJ 1137

Aug 1st, 2021
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13.  
  14. double L,n,C,s,L1;
  15.  
  16. cin>>L>>n>>C;
  17.  
  18. L1 = (1 + n * C) * L;
  19.  
  20. double lo=0.0,hi=L/2.00,mid,r,theta;
  21.  
  22. while(hi-lo>(1e-9))
  23. {
  24. mid=(lo+hi)/2;
  25.  
  26. r=(mid/2.00)+(L*L)/(8.00*mid);
  27.  
  28. theta= 2.0*asin((L/2.00)/r);
  29.  
  30. s=r*theta;
  31.  
  32. if(s>=L1)
  33. {
  34. hi=mid;
  35. }
  36. else lo=mid;
  37.  
  38. }
  39.  
  40. cout<<"Case "<<cs<<": "<<fixed<<setprecision(10)<<lo<<endl;
  41.  
  42. }
  43.  
  44.  
  45. return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement