Advertisement
Guest User

XVII OpenCup - Gran Prix of Eurasia - Problem 12

a guest
Oct 2nd, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const long double pi = 3.1415926535897932384626433832795;
  6.  
  7. const long double EPS = 1e-7;
  8.  
  9. long double px, py, qx, qy;
  10. long double ux, uy;
  11. long double v;
  12. int n;
  13.  
  14. int main()
  15. {
  16.     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  17.  
  18.     //freopen("","r",stdin);
  19.     //freopen("","w",stdout);
  20.  
  21.     cin >> px >> py >> qx >> qy >> ux >> uy >> v >> n;
  22.  
  23.     long double x, y;
  24.     x = qx-px;
  25.     y = qy-py;
  26.     long double r = sqrt(x*x + y*y);
  27.     for(int i = 0; i < n; i++){
  28.         long double t;
  29.         cin >> t;
  30.  
  31.         long double cycles = t*v/2/pi/r;
  32.         cycles -= (int)cycles;
  33.  
  34.         long double degree = cycles*2*pi;
  35.  
  36.         long double cosd = cos(degree);
  37.         long double sind = sin(degree);
  38.  
  39.         long double endx, endy;
  40.  
  41.         endx = (x*cosd - y*sind) + px;
  42.         endy = (x*sind + y*cosd) + py;
  43.  
  44.         endx += ux*t;
  45.         endy += uy*t;
  46.  
  47.         cout << endx << " " << endy << endl;
  48.     }
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement