Advertisement
Malinovsky239

12

Oct 8th, 2011
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. struct vect {
  8.     int x, y;
  9.  
  10.     void read() {
  11.         cin >> x >> y;
  12.     }
  13.  
  14.     vect() {}
  15.  
  16.     vect(int a, int b) {
  17.         x = a, y = b;      
  18.     }
  19. };
  20.  
  21. vect operator - (vect a, vect b) {
  22.     return vect(a.x - b.x, a.y - b.y);
  23. }
  24.  
  25. int operator * (vect a, vect b) {
  26.     return a.x * b.y - a.y * b.x;
  27. }
  28.  
  29. vect v[5];
  30.  
  31. int main() {
  32.     freopen("input.txt", "r", stdin);
  33.     freopen("output.txt", "w", stdout);
  34.  
  35.     int n, res = 0, sum, s;
  36.     cin >> n;
  37.  
  38.     for (int i = 0; i < n; i++) {
  39.  
  40.         sum = s = 0;
  41.         vect p;
  42.         p.read();
  43.         for (int j = 0; j < 4; j++)
  44.             v[j].read();                       
  45.         v[4] = v[0];
  46.  
  47.         for (int j = 0; j < 4; j++)
  48.             sum += abs((v[j] - p) * (v[j + 1] - p));
  49.  
  50.         p = v[0];
  51.         for (int j = 0; j < 4; j++)
  52.             s += abs((v[j] - p) * (v[j + 1] - p));
  53.  
  54.         if (s == sum) res++;
  55.     }
  56.  
  57.     cout << res;
  58.  
  59.     return 0;
  60. }
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement