Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct Point
- {
- double x, y;
- Point(double x0 = 0, double y0 = 0) {
- x = x0;
- y = y0;
- }
- };
- istream & operator >> (istream & in, Point& P) {
- return in >> P.x >> P.y;
- }
- struct Vector
- {
- double x, y;
- Vector(Point A, Point B) {
- y = B.y - A.y;
- x = B.x - A.x;
- }
- double len() {
- return sqrt(y * y + x * x);
- }
- };
- double cross_product(Vector& A, Vector& B) {
- return A.x * B.y - A.y * B.x;
- }
- int main()
- {
- int n;
- cin >> n;
- int sum = 0;
- for (int i = 0; i < n; ++i) {
- Point F, A, B, C, D;
- cin >> F >> A >> B >> C >> D;
- Vector AF(A, F), BF(B, F), CF(C, F), DF(D, F), AB(A, B), BC(B, C), CD(C, D), DA(D, A);
- if (cross_product(AB, AF) >= 0 && cross_product(BC, BF) >= 0 && cross_product(CD, CF) >= 0 && cross_product(DA, DF) >= 0 || cross_product(AB, AF) <= 0 && cross_product(BC, BF) <= 0 && cross_product(CD, CF) <= 0 && cross_product(DA, DF) <= 0) {
- sum++;
- }
- }
- cout << sum;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement