Advertisement
Guest User

120SGU

a guest
Oct 27th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <complex>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. typedef complex<double> point;
  9.  
  10. const int maxn = 200;
  11. const double pi = acos(-1);
  12.  
  13. int n, n1, n2;
  14. point a, b, center;
  15. double r;
  16. point ans[maxn];
  17.  
  18. void calc();
  19. void rot();
  20.  
  21. int main() {
  22.     ios :: sync_with_stdio(false);
  23.     cin >> n >> n1 >> n2;
  24.     n1--, n2--;
  25.     double x, y;
  26.     cin >> x >> y;
  27.     a = point(x, y);
  28.     cin >> x >> y;
  29.     b = point(x, y);
  30.  
  31.     if (a == b) {
  32.         for (int i = 0; i < n; i++)
  33.             cout << real(a) << " " << imag(a) << '\n';
  34.         return 0;
  35.     }
  36.  
  37.     calc();
  38.     a -= center;
  39.     for (int i = 0; i < n; i++) {
  40.         ans[n1] = a + center;
  41.         rot();
  42.         n1--;
  43.         if (n1 < 0)
  44.             n1 += n;
  45.     }
  46.  
  47.     for (int i = 0; i < n; i++)
  48.         cout << setprecision(6) << fixed << real(ans[i]) << " " << imag(ans[i]) << '\n';
  49.  
  50.     return 0;
  51. }
  52.  
  53. void calc() {
  54.     double dis = abs(b - a);
  55.     double z = (2 * pi) / n;
  56.     z *= (max(n2, n1) - min(n2, n1));
  57.     z /= 2;
  58.     r = dis / sin(z);
  59.     r /= 2;
  60.     z *= 2;
  61.     //if (z > pi)
  62.     //  swap(a, b), c = true;
  63.     z = (z - pi) / 2;
  64.     double len = r / dis;
  65.     center = (b - a) * point(len * cos(z), len * sin(z)) + a;
  66. }
  67.  
  68. void rot() {
  69.     double z = (2 * pi) / n;
  70.     a = a * point(cos(z),  sin(z));
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement