Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define DEBUG
- using namespace std;
- #pragma GCC target ("avx2")
- #pragma GCC optimization ("O3")
- #pragma GCC optimization ("unroll-loops")
- typedef long long ll;
- typedef long double ld;
- const ld Pi = acosl(-1.0);
- struct Point
- {
- ll x, y;
- Point() {}
- Point(ll _x, ll _y) { x = _x; y = _y; }
- friend istream& operator >> (istream &in, Point &a) {
- in >> a.x >> a.y;
- return in;
- }
- };
- struct Line
- {
- ll a, b, c;
- Line() {}
- Line(Point A, Point B) { // Задать прямую двумя точками
- a = A.y - B.y;
- b = B.x - A.x;
- c = A.x * B.y - B.x * A.y;
- }
- ld operator^(Line B) { // Угол между двумя прямыми
- return acosl( ( a * B.a + b * B.b ) / ( sqrtl( a * a + b * b ) * sqrtl( B.a * B.a + B.b * B.b ) ) );
- }
- bool operator==(Line B) {
- return a == B.a && b == B.b && c == B.c;
- }
- };
- int main() {
- // ios_base::sync_with_stdio(0);
- // cin.tie(NULL);
- #ifdef DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #else
- freopen("crossline.in", "r", stdin);
- freopen("crossline.out", "w", stdout);
- #endif
- Point a, b, c, d;
- cin >> a >> b >> c >> d;
- Line f(a, b);
- Line s(c, d);
- if(f == s) {
- cout << "infinite";
- return 0;
- }
- if((f ^ s) == Pi) { // Если угол между двумя прямыми равен 180 градусам, то они параллельны.
- cout << "parallel";
- return 0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment