Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0,
where ai and biare
not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the point where at least two different roads intersect.

Your home is located in one of the blocks. Today you need to get to the University, also located in some block. In one step you can move from one block to another, if the length of their common border is nonzero (in particular, this means that if the blocks
are adjacent to one intersection, but have no shared nonzero boundary segment, then it are not allowed to move from one to another one in one step).

Determine what is the minimum number of steps you have to perform to get to the block containing the university. It is guaranteed that neither your home nor the university is located on the road.

Input

The first line contains two space-separated integers x1, y1 ( - 106 ≤ x1, y1 ≤ 106)
— the coordinates of your home.

The second line contains two integers separated by a space x2, y2 ( - 106 ≤ x2, y2 ≤ 106)
— the coordinates of the university you are studying at.

The third line contains an integer n (1 ≤ n ≤ 300)
— the number of roads in the city. The following n lines contain 3 space-separated integers ( - 106 ≤ ai, bi, ci ≤ 106; |ai| + |bi| > 0)
— the coefficients of the line aix + biy + ci = 0,
defining the i-th road. It is guaranteed that no two roads are the same. In addition, neither your home nor the university lie on the road (i.e. they do
not belong to any one of the lines).

Output

Output the answer to the problem.

Sample test(s)
input
1 1
-1 -1
2
0 1 0
1 0 0
output
2
input
1 1
-1 -1
3
1 0 0
0 1 0
1 1 -3
output
2
Note

Pictures to the samples are presented below (A is the point representing the house; B is the point representing the university, different blocks are filled with different colors):

这题想通后很简单,就是看A,B两点间的直线有几条,用零点法看是否一正一负就行。注意一点要分两种情况讨论,不然会爆__int64.

#include<stdio.h>

#include<string.h>

int main()

{
__int64 x1,y1,x2,y2,i,j,a,b,c;
int n,sum;
while(scanf("%I64d%I64d",&x1,&y1)!=EOF)
{
scanf("%I64d%I64d",&x2,&y2);
scanf("%d",&n);
sum=0;
for(i=1;i<=n;i++){
scanf("%I64d%I64d%I64d",&a,&b,&c);
if(a*x1+b*y1+c>0 && a*x2+b*y2+c<0){
sum++;continue;
}
if(a*x1+b*y1+c<0 && a*x2+b*y2+c>0){
sum++;continue;
}
}
printf("%d\n",sum);
}

}

最新文章

  1. Post方式打开新窗口
  2. ssh架构简单解释和vo po解释
  3. C++ 线程类的一个实现
  4. JAVA关系运算符
  5. Android Studio实用快捷键汇总
  6. php 换行 PHP_EOL变量
  7. cocos2d-x CCListView
  8. Linux IIO子系统分析
  9. 关于WinForm/Web如何使用缓存Cach
  10. C#共享内存实例 附源码
  11. MD5和Base64
  12. Nginx的反向代理与负载均衡
  13. Java并发编程的艺术读书笔记(1)-并发编程的挑战
  14. php curl 上传json数据
  15. gtest 学习
  16. javascript监听数组变化
  17. 机器学习算法中的偏差-方差权衡(Bias-Variance Tradeoff)
  18. Java反射之如何判断类或变量、方法的修饰符(Modifier解析)
  19. C#的两种类据类型:值类型和引用类型
  20. Jmeter发送某个request时而成功,时而失败(处理办法:失败的时候尝试重新发送这个HTTP request)

热门文章

  1. innnodb_doublewrite
  2. 【Linux】系统打开文件最大数量限制(进程打开的最大文件句柄数设置)
  3. 【开源】我和 JAP(JA Plus) 的故事
  4. WeihanLi.Npoi 1.14.0 Release Notes
  5. 三十三:WEB漏洞-逻辑越权之水平垂直越权
  6. win 10下Apache和PHP的安装配置
  7. secrets 管理工具 Vault 的介绍、安装及使用
  8. (02)-Python3之--列表(list)操作
  9. 解决Linux下mysql区分大小写的问题
  10. day132:2RenMJ:MJ需求文档&amp;MJ游戏流程&amp;Egret白鹭引擎安装&amp;TypeScript简要介绍