Advertisement
Emiliatan

e144

Apr 6th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. /* e144            */
  2. /* AC (2ms, 136KB) */
  3. #include <cstdio>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. const double g = 9.8, pi = acos(-1.0);
  9. int angle, v0, t, T;
  10. double Vy, Vx, Sy, Sx;
  11.  
  12. double Convert(int a)
  13. {
  14.     return (double)a * pi / 180;
  15. }
  16.  
  17. int main()
  18. {
  19.     scanf("%d", &T);
  20.     while(T-- && ~scanf("%d %d %d", &v0, &angle, &t))
  21.     {
  22.         if(angle == 360) angle = 0;
  23.         Vx = v0 * cos(Convert(angle));
  24.         Vy = v0 * sin(Convert(angle)) - g * t;
  25.         Sx = Vx * t;
  26.         Sy = v0 * sin(angle * pi / 180) * t - g * t * t / 2;
  27.  
  28.         if(abs(Sx - 0.0) <= 1e-6) Sx = 0.0;
  29.         if(abs(Sy - 0.0) <= 1e-6) Sy = 0.0;
  30.         printf("x: %.2f, y: %.2f  at %d(s) ", Sx, Sy, t);
  31.  
  32.         if(abs(Vy - 0.0) <= 1e-6) printf("rest");
  33.         else if(Vy > 0.0) printf("rising");
  34.         else printf("falling");
  35.         puts("");
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement