B. Intersection

time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0.

Write the program which finds the number of points in the intersection of two given sets.

Input

The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive.

Output

Print the number of points in the intersection or -1 if there are infinite number of points.

Examples

input

1 1 0

2 2 0

output

-1

input

1 1 0

2 -2 0

output

1

模拟

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h> using namespace std;
int a1,b1,c1;
int a2,b2,c2;
int main()
{
scanf("%d%d%d%d%d%d",&a1,&b1,&c1,&a2,&b2,&c2);
if((a1==0&&b1==0&&c1!=0)||(a2==0&&b2==0&&c2!=0))
{cout<<0<<endl;return 0;}
if((a1==0&&b1==0&&c1==0)||(a2==0&&b2==0&&c2==0))
{cout<<-1<<endl;return 0;}
if((a1==0&&a2!=0)||(a1!=0&&a2==0))
{cout<<1<<endl;return 0;}
if(a1==0&&a2==0)
{
double k1=1.0*c1/b1;
double k2=1.0*c2/b2;
if(k1==k2)
{cout<<-1<<endl;return 0;}
else
{cout<<0<<endl;return 0;}
}
if((b1==0&&b2!=0)||(b1!=0&&b2==0))
{cout<<1<<endl;return 0;}
if(b1==0&&b2==0)
{
double k1=1.0*c1/a1;
double k2=1.0*c2/a2;
if(k1==k2)
{cout<<-1<<endl;return 0;}
else
{cout<<0<<endl;return 0;}
}
if((b1==0&&a2==0)||(b2==0&&a1==0))
{cout<<1<<endl;return 0;}
double k1=1.0*a1/b1;
double k2=1.0*a2/b2;
if(k1==k2)
{
if((c1==0&&c2!=0)||(c1!=0&&c2==0))
{cout<<0<<endl;return 0;}
if(c1==0&&c2==0)
{
double kk1=1.0*a1/a2;
double kk2=1.0*b1/b2;
if(kk1==kk2)
{cout<<-1<<endl;return 0;}
else
{cout<<0<<endl;return 0;}
}
else
{
double kk1=1.0*a1/a2;
double kk2=1.0*b1/b2;
double kk3=1.0*c1/c2;
if(kk1==kk2&&kk2==kk3)
{cout<<-1<<endl;return 0;}
else
{cout<<0<<endl;return 0;}
}
}
else
{
cout<<1<<endl;return 0;
}
}

Code Force 21B Intersection的更多相关文章

  1. pycharm debug后会出现 step over /step into/step into my code /force step into /step out 分别表示

    1.debug,全部打印 2.打断点debug,出现单步调试等按钮,只运行断点前 3.setup over 调试一行代码 4.setup out 运行断点后面所有代码 5.debug窗口显示调试按钮 ...

  2. 【Code Force】Round #589 (Div. 2) D、Complete Tripartite

    题目链接 大致题意 把一个图分成三块,要求任意两块之间是完全图,块内部没有连线 分析 首先根据块内没有连线可以直接分成两块 假定点1是属于块1的,那么所有与点1连接的点,都不属于块1:反之则是块1的 ...

  3. code force 424 A - Office Keys

    There are n people and k keys on a straight line. Every person wants to get to the office which is l ...

  4. code force 403C.C. Andryusha and Colored Balloons

    C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes ...

  5. code force 403B.B. The Meeting Place Cannot Be Changed

    B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megab ...

  6. code force 401B. Game of Credit Cards

    B. Game of Credit Cards time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. Code Force 429B Working out【递推dp】

    Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the ...

  8. code force 1228C

    算是一题普通数论+思维题吧. 大概很多人是被题意绕晕了. 思路: 首先常规操作求出X的质因子. 然后题目要求的是,X的每个质因子p,在g(i,p)的连乘.i∈[1,n]: 我们转换下思维,不求每一个g ...

  9. .htaccess 基础教程(三)RewriteCond标志符,RewriteRule适用的标志符

    1.利用 .htaccess 防止盗链 如果不喜欢别人在他们的网页上链接自己的图片.文档的话,也可以通过htaccess的指令来做到.当然这样也可以对你的网站服务器压力变小! 这次先给出‘代码’,然后 ...

随机推荐

  1. atitit.orm的缺点与orm框架市场占有率,选型attilax总结

    atitit.orm的缺点与orm框架市场占有率,选型attilax总结 1. attilax的orm框架要求 1 2. orm框架市场占有率 2 3. spring jdbc templt 3 4. ...

  2. Nginx - rewrite 不区分大小写进行匹配

    Nginx - rewrite 不区分大小写进行匹配 分类: Nginx2014-05-28 19:25 1046人阅读 评论(0) 收藏 举报 Use (?i) to match case-inse ...

  3. 危险系数 set容器

    题目描述 抗日战争时期,冀中平原的地道战曾发挥重要作用. 地道的多个站点间有通道连接,形成了庞大的网络.但也有隐患,当敌人发现了某个站点后,其它站点间可能因此会失去联系. 我们来定义一个危险系数DF( ...

  4. CentOS 6.2下SVN安装与使用

    1.安装 CentOS安装TortoiseSVN yum install -y subversion 2.常用命令详解 1.将文件checkout到本地目录svn checkout path(path ...

  5. thinkphp 原生sql使用分页类

    public function index(){ import("@.ORG.Page"); //导入分页类 $Dao = M(); $count = count($Dao-> ...

  6. 以下web.xml片断( )正确地声明servlet 上下文参数。

    A <init-param> <param-name>MAX</param-name> <param-value>100</param-value ...

  7. import是page指令的一个属性。

    以下不属于JSP的标准指令的是.(选择1项) A.Taglib B.Include C.Import D.Page 解答:C

  8. 【BZOJ】2555: SubString(后缀自动机)

    http://www.lydsy.com/JudgeOnline/problem.php?id=2555 学到了如何快速维护right值orz (不过这仍然是暴力维护,可以卡到O(n) 首先我们在加一 ...

  9. (转)Spring AOP编程原理、Demo

    转自: http://pandonix.iteye.com/blog/336873/ AOP原理: http://blog.csdn.net/moreevan/article/details/1197 ...

  10. HDU 1284 钱币兑换问题(全然背包:入门题)

    HDU 1284 钱币兑换问题(全然背包:入门题) http://acm.hdu.edu.cn/showproblem.php?pid=1284 题意: 在一个国家仅有1分,2分.3分硬币,将钱N ( ...