fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct Point {
  5. double x, y;
  6. };
  7.  
  8. double getArea(Point a, Point b, Point c) {
  9. return 0.5 * abs(a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y));
  10. }
  11.  
  12. bool isInTriangle(Point X, Point A, Point B, Point C) {
  13. double s = getArea(A, B, C);
  14. double s1 = getArea(A, B, X);
  15. double s2 = getArea(B, C, X);
  16. double s3 = getArea(A, C, X);
  17. return (s == s1 + s2 + s3);
  18. }
  19.  
  20. int main() {
  21. Point A, B, C;
  22. cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
  23. int n, counter = 0;
  24. cin >> n;
  25. while (n--) {
  26. Point X;
  27. cin >> X.x >> X.y;
  28. counter += isInTriangle(X, A, B, C);
  29. }
  30. cout << setprecision(2) << fixed << getArea(A, B, C) << '\n';
  31. cout << counter;
  32. }
  33.  
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
0.00
5394