Advertisement
momo2345

expanding rods

Sep 16th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define suni ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
  4. #define endl "\n"
  5. #define mn int main()
  6. #define frac() cout.unsetf(ios::floatfield);cout.precision(6);cout.setf(ios::fixed,ios::floatfield);
  7. typedef long long ll;
  8. mn
  9. {
  10.     suni;
  11.     int t; cin>>t;
  12.     for(int i=1;i<=t;i++){
  13.         double L,n,c;
  14.         cin>>L>>n>>c;
  15.         double L1=(1+(n*c))*L;
  16.         double l=0,r=1e18;
  17.         for(int j=1;j<=100;j++){
  18.             double R=(l+r)/2.0;
  19.             double ans=R*2*asin(L/(2.0*R));
  20.             if(ans>L1) l=R;
  21.             else r=R;
  22.         }
  23.         double R=l;
  24.         double h=R-sqrt((R*R)-(L/2.0)*(L/2.0));
  25.         frac();
  26.         cout<<"Case "<<i<<": "<<h<<endl;
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement