Advertisement
MegaVerkruzo

acmp_12

Sep 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. struct Point
  6. {
  7. double x, y;
  8. Point(double x0 = 0, double y0 = 0) {
  9. x = x0;
  10. y = y0;
  11. }
  12. };
  13.  
  14. istream & operator >> (istream & in, Point& P) {
  15. return in >> P.x >> P.y;
  16. }
  17.  
  18. struct Vector
  19. {
  20. double x, y;
  21. Vector(Point A, Point B) {
  22. y = B.y - A.y;
  23. x = B.x - A.x;
  24. }
  25. double len() {
  26. return sqrt(y * y + x * x);
  27. }
  28. };
  29.  
  30. double cross_product(Vector& A, Vector& B) {
  31. return A.x * B.y - A.y * B.x;
  32. }
  33.  
  34. int main()
  35. {
  36. int n;
  37. cin >> n;
  38. int sum = 0;
  39. for (int i = 0; i < n; ++i) {
  40. Point F, A, B, C, D;
  41. cin >> F >> A >> B >> C >> D;
  42. 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);
  43. 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) {
  44. sum++;
  45. }
  46. }
  47. cout << sum;
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement