FEgor04

Untitled

Aug 13th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define DEBUG
  3. using namespace std;
  4. #pragma GCC target ("avx2")
  5. #pragma GCC optimization ("O3")
  6. #pragma GCC optimization ("unroll-loops")
  7.  
  8. typedef long long ll;
  9. typedef long double ld;
  10.  
  11. const ld Pi = acosl(-1.0);
  12.  
  13. struct Point
  14. {
  15.     ll x, y;
  16.     Point() {}
  17.     Point(ll _x, ll _y) { x = _x; y = _y; }
  18.     friend istream& operator >> (istream &in, Point &a) {
  19.         in >> a.x >> a.y;
  20.         return in;
  21.     }
  22. };
  23.  
  24. struct Line
  25. {
  26.     ll a, b, c;
  27.     Line() {}
  28.     Line(Point A, Point B) {    // Задать прямую двумя точками
  29.         a = A.y - B.y;
  30.         b = B.x - A.x;
  31.         c = A.x * B.y - B.x * A.y;
  32.     }
  33.     ld operator^(Line B) {  //  Угол между двумя прямыми
  34.         return acosl( ( a * B.a + b * B.b ) / ( sqrtl( a * a + b * b ) * sqrtl( B.a * B.a + B.b * B.b ) ) );
  35.     }
  36.     bool operator==(Line B) {
  37.         return a == B.a && b == B.b && c == B.c;
  38.     }
  39. };
  40.  
  41. int main() {
  42.     // ios_base::sync_with_stdio(0);
  43.     // cin.tie(NULL);
  44.     #ifdef DEBUG
  45.         freopen("input.txt", "r", stdin);
  46.         freopen("output.txt", "w", stdout);
  47.     #else
  48.         freopen("crossline.in", "r", stdin);
  49.         freopen("crossline.out", "w", stdout);
  50.     #endif
  51.     Point a, b, c, d;
  52.     cin >> a >> b >> c >> d;
  53.     Line f(a, b);
  54.     Line s(c, d);
  55.     if(f == s) {
  56.         cout << "infinite";
  57.         return 0;
  58.     }
  59.     if((f ^ s) == Pi) { //  Если угол между двумя прямыми равен 180 градусам, то они параллельны.
  60.         cout << "parallel";
  61.         return 0;
  62.     }
  63.    
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment