# Задача: дачники (работает)

Apr 8th, 2016
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. n = int(input())
2. count = 0
3. def line(x,y,x1,y1,x2,y2,x3,y3):
4.     if x1 == x2:
5.         if x1 >= x3 and x1 >= x: return True
6.         elif x1 <= x3 and x1 <= x: return True
7.         else: return False
8.     elif y1 == y2:
9.         if y1 >= y3 and  y1 >= y: return True
10.         elif y1 <= y3 and y1 <= y: return True
11.         else: return False
12.     else:
13.         x0 = x1-x2
14.         y0 = y1-y2
15.         k = y0/x0
16.         b = y1-x1*k
17.         if y3 >= k*x3+b and y >= k*x+b: return True
18.         elif y3 <= k*x3+b and y <= k*x+b: return True
19.         else: return False
20.
21. for i in range(n):
22.     (x,y,x1,y1,x2,y2,x3,y3,x4,y4) = map(int,input().split())
23.     if line(x,y,x1,y1,x2,y2,x3,y3) and line(x,y,x2,y2,x3,y3,x4,y4) and line(x,y,x3,y3,x4,y4,x1,y1) and line(x,y,x4,y4,x1,y1,x2,y2):
24.         count+=1
25. print(count)
RAW Paste Data