smatskevich

Seminar2

Jan 25th, 2025
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.41 KB | None | 0 0
  1. #include <algorithm>
  2. #include <array>
  3. #include <cassert>
  4. #include <climits>
  5. #include <cmath>
  6. #include <cstring>
  7. #include <iomanip>
  8. #include <iostream>
  9. #include <limits>
  10. #include <list>
  11. #include <map>
  12. #include <numeric>
  13. #include <queue>
  14. #include <set>
  15. #include <sstream>
  16. #include <stack>
  17. #include <string>
  18. #include <tuple>
  19. #include <unordered_map>
  20. #include <unordered_set>
  21. #include <vector>
  22.  
  23. #define all(x) x.begin(), x.end()
  24. using namespace std;
  25. using ll = long long;
  26. using ld = long double;
  27. const double eps = 1e-10;
  28. const int mod = 1000000007;
  29.  
  30. struct Point { ld x; ld y; };
  31. struct Vector { ld x; ld y; };
  32. ld Len(const Vector& v) { return hypot(v.x, v.y); }
  33. ld SqLen(const Vector& v) { return v.x * v.x + v.y * v.y; }
  34. ld Distance(const Point& lhs, const Point& rhs) { return Len(rhs - lhs); }
  35. Vector operator-(const Vector& v) { return {-v.x, -v.y}; }
  36. Vector operator+(const Vector& lhs, const Vector& rhs) { return {lhs.x + rhs.x, lhs.y + rhs.y}; }
  37. Vector operator-(const Vector& lhs, const Vector& rhs) { return {lhs.x - rhs.x, lhs.y - rhs.y}; }
  38. Vector operator-(const Point& lhs, const Point& rhs) { return {lhs.x - rhs.x, lhs.y - rhs.y}; }
  39. Point operator+(const Point& lhs, const Vector& rhs) { return {lhs.x + rhs.x, lhs.y + rhs.y}; }
  40. Point operator-(const Point& lhs, const Vector& rhs) { return {lhs.x - rhs.x, lhs.y - rhs.y}; }
  41. Vector operator*(ld c, const Vector& v) { return {c * v.x, c * v.y}; }
  42. Vector operator*(const Vector& v, ld c) { return {c * v.x, c * v.y}; }
  43. Vector operator/(const Vector& v, ld c) { return {v.x / c, v.y / c}; }
  44. istream& operator>>(istream& in, Point& p) { return in >> p.x >> p.y; }
  45. istream& operator>>(istream& in, Vector& v) { return in >> v.x >> v.y; }
  46. ostream& operator<<(ostream& out, const Point& p) { return out << p.x << " " << p.y; }
  47. ostream& operator<<(ostream& out, const Vector& v) { return out << v.x << " " << v.y; }
  48. ld DotProduct(const Vector& lhs, const Vector& rhs) { return lhs.x * rhs.x + lhs.y * rhs.y; }
  49. ld CrossProduct(const Vector& lhs, const Vector& rhs) { return lhs.x * rhs.y - lhs.y * rhs.x; }
  50. Vector Normalize(const Vector& v) { return v / Len(v); }
  51. Vector Rotate(const Vector& v, ld alpha) { return {v.x * cos(alpha) - v.y * sin(alpha), v.x * sin(alpha) + v.y * cos(alpha)}; }
  52.  
  53. int main() {
  54.   ios::sync_with_stdio(false);
  55.   cin.tie(nullptr);
  56.   cout.tie(nullptr);
  57.  
  58.   Point a, b; cin >> a >> b;
  59.   cout << b - a << "\n";
  60.  
  61.   return 0;
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment