Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <set>
  6. #include <map>
  7. #include <queue>
  8. #include <iomanip>
  9. #include <cassert>
  10. #include <cmath>
  11. #include <deque>
  12. using namespace std;
  13.  
  14. #define pb push_back
  15. #define re return
  16. #define int long double
  17.  
  18. struct pt
  19. {
  20. int x, y;
  21. int len()
  22. {
  23. return sqrt(x * x + y * y);
  24. }
  25. };
  26.  
  27. pt vec(pt a, pt b)
  28. {
  29. return { b.x - a.x, b.y - a.y };
  30. }
  31.  
  32. signed main()
  33. {
  34. ios_base::sync_with_stdio(false);
  35.  
  36. pt a, b, c;
  37. cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
  38.  
  39. int A1 = b.y - a.y, B1 = -1 * (b.x - a.x), C1 = a.y * (b.x - a.x) - a.x * (b.y - a.y);
  40. int A2 = c.y - a.y, B2 = -1 * (c.x - a.x), C2 = a.y * (c.x - a.x) - a.x * (c.y - a.y);
  41.  
  42. int z = sqrt(A2 * A2 + B2 * B2), z2 = sqrt(A1 * A1 + B1 * B1);
  43.  
  44. int A3 = A1 * z + A2 * z2, B3 = B1 * z + B2 * z2, C3 = C1 * z + C2 * z2;
  45.  
  46. if ((A3 * b.x + B3 * b.y + C3 > 0 && A3 * c.x + B3 * c.y + C3 < 0) || (A3 * b.x + B3 * b.y + C3 < 0 && A3 * c.x + B3 * c.y + C3 > 0))
  47. {
  48. cout << A3 << " " << B3 << " " << C3 << endl;
  49. }
  50. else
  51. {
  52. cout << A1 * z - A2 * z2 << " " << B1 * z - B2 * z2 << " " << C1 * z - C2 * z2 << endl;
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement