Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define pi 3.14159265359
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8. int main()
  9. {
  10.     double w,x1,y1,x,t;
  11.     int tt;
  12.     scanf("%d",&tt);
  13.     for(int kk1=1;kk1<=tt;kk1++)
  14.     {
  15.         scanf("%lf%lf%lf%lf%lf",&x1,&y1,&x,&w,&t);
  16.         double thet;
  17.         bool fg =false;
  18.         thet = t*w;
  19.         if(thet<0.0)
  20.         {
  21.             fg = true;
  22.             thet = thet*(-1.0);
  23.         }
  24.         double d,r;
  25.         r = sqrt((x1*x1)+(y1*y1));
  26.         d = sqrt(((x1-x)*(x1-x))+((y1-0)*(y1-0)));
  27.         double th1,th2;
  28.         th1 = (180.00*thet)/pi;
  29.         th2 = acos((-d*d+x*x+r*r)/(2.00*x*r));
  30.         double rad;
  31.         th2 = (180.00*th2)/pi;
  32.         if(fg)
  33.         th1 = th2-th1;
  34.         else
  35.         th1 = th2+th1;
  36.         rad = (pi*th1)/180.00;
  37.    //     cout<<th1<<endl;
  38.    //     cout<<cos(rad)<<endl;
  39.         double a,b,c;
  40.         b=2.00*r*cos(rad);
  41.         a=1.00;
  42.         c=(-1.0)*(d*d-r*r);
  43.         b=b*(-1);
  44.  
  45. //        cout<<a<<" "<<b<<" "<<c<<endl;
  46.         double ans1,ans2;
  47.         ans1 = (-b+sqrt(b*b-4.00*a*c))/2.00*a;
  48.         ans2 = (-b-sqrt(b*b-4.00*a*c))/2.00*a;
  49.  
  50.  //       cout<<ans1<<"  "<<ans2<<endl;
  51.         ans1 =max(ans1,ans2);
  52.         printf("Case %d: ",kk1);
  53.  
  54.         printf("%.10lf\n",ans1);
  55.  
  56.  
  57.  
  58.  
  59.     }
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement