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;
}
}

最新文章

  1. sublime text之sublimeCodeIntel 的配置
  2. c语言的字符串操作(比较详细)
  3. MyEclipse管理部署Maven项目 供调试
  4. Lua:简单入门
  5. 推荐:室内定位API - indoor Location API
  6. win7 x64 jdk1.7.0_51
  7. 多线程编程学习笔记——异步调用WCF服务
  8. Linux(CentOS)下,下载安装Nginx并配置
  9. Android基础系列合集
  10. Kattis之旅——Prime Reduction
  11. [BZOJ 4350]括号序列再战猪猪侠 题解(区间DP)
  12. P2059 [JLOI2013]卡牌游戏
  13. dTree 动态生成树
  14. EMQ 注意事项
  15. JavaScript&amp;jQuery获取url参数方法
  16. uwsgi配置文件
  17. exa命令详解
  18. 总结下常用js中的小语法和技巧
  19. [转载]中情局数千份机密文档泄露:各种0day工具、恶意程序应有尽有
  20. 在DOS行下设置静态IP

热门文章

  1. 0x00 译文:Windows桌面应用入门选择
  2. Atitit.js javascript异常处理机制与java异常的转换.js exception process Voae
  3. gdb前端: VIM+Pyclewn 调试C/C++
  4. linux 流量控制全攻略(TC)
  5. cocos2dx 3.x 开发环境搭建
  6. 一款基于jQuery的热点新闻Tab选项卡插件
  7. 解决Access denied for user &amp;#39;&amp;#39;@&amp;#39;localhost&amp;#39; to database &amp;#39;mysql&amp;#39;问题
  8. Android基础总结(四)网络通信
  9. Linux curl 模拟form表单提交信息和文件
  10. cs108 03 ( 调试, java通用性)