Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.

He noticed that the two rabbits were hopping towards each other. The positions of the two rabbits can be represented as integer coordinates on a horizontal line. The taller rabbit is currently on position xx , and the shorter rabbit is currently on position yy (x<yx<y ). Every second, each rabbit hops to another position. The taller rabbit hops to the positive direction by aa , and the shorter rabbit hops to the negative direction by bb .

For example, let's say x=0x=0 , y=10y=10 , a=2a=2 , and b=3b=3 . At the 11 -st second, each rabbit will be at position 22 and 77 . At the 22 -nd second, both rabbits will be at position 44 .

Gildong is now wondering: Will the two rabbits be at the same position at the same moment? If so, how long will it take? Let's find a moment in time (in seconds) after which the rabbits will be at the same point.

Input

Each test contains one or more test cases. The first line contains the number of test cases tt (1≤t≤10001≤t≤1000 ).

Each test case contains exactly one line. The line consists of four integers xx , yy , aa , bb (0≤x<y≤1090≤x<y≤109 , 1≤a,b≤1091≤a,b≤109 ) — the current position of the taller rabbit, the current position of the shorter rabbit, the hopping distance of the taller rabbit, and the hopping distance of the shorter rabbit, respectively.

Output

For each test case, print the single integer: number of seconds the two rabbits will take to be at the same position.

If the two rabbits will never be at the same position simultaneously, print −1−1 .

Example

Input
5
0 10 2 3
0 10 3 3
900000000 1000000000 1 9999999
1 2 1 1
1 3 1 1
Output
2
-1
10
-1
1 小学生水题,就是路程问题,不能整除的话输出-1。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long a,b,x,y;
cin>>x>>y>>a>>b;
long long ans=;
if((y-x)%(a+b)==)
{
ans=(y-x)/(a+b);
}
else ans=-;
cout<<ans<<endl;
}
return ;
}

Codeforces Round #620 (Div. 2) A. Two Rabbits的更多相关文章

  1. Codeforces Round #620 (Div. 2)

    Codeforces Round #620 (Div. 2) A. Two Rabbits 题意 两只兔子相向而跳,一只一次跳距离a,另一只一次跳距离b,每次同时跳,问是否可能到同一位置 题解 每次跳 ...

  2. Codeforces Round #620 (Div. 2) A-F代码 (暂无记录题解)

    A. Two Rabbits (手速题) #include<bits/stdc++.h> using namespace std; typedef long long ll; int ma ...

  3. Codeforces Round #620 (Div. 2) 题解

    A. Two Rabbits 思路: 很明显,如果(y-x)%(a+b)==0的话ans=(y-x)/(a+b),否则就为-1 #include<iostream> #include< ...

  4. Codeforces Round #620 (Div. 2)E LCA

    题:https://codeforces.com/contest/1304/problem/E 题意:给定一颗树,边权为1,m次询问,每次询问给定x,y,a,b,k,问能否在原树上添加x到y的边,a到 ...

  5. Codeforces Round #620 (Div. 2)D dilworld定理

    题:https://codeforces.com/contest/1304/problem/D 题意:给定长度为n-1的只含’>'和‘<’的字符串,让你构造出俩个排列,俩个排列相邻的数字之 ...

  6. Codeforces Round #620 (Div. 2) D

    构造一个排列,要求相邻之间的数满足给定的大小关系,然后构造出两个序列,一个序列是所有可能的序列中LIS最长的,一个所有可能的序列中LIS最短的 最短的构造方法:我们考虑所有单调递增的部分,可以发现要让 ...

  7. Codeforces Round #620 (Div. 2)E(LCA求树上两点最短距离)

    LCA求树上两点最短距离,如果a,b之间距离小于等于k并且奇偶性与k相同显然YES:或者可以从a先走到x再走到y再走到b,并且a,x之间距离加b,y之间距离+1小于等于k并且奇偶性与k相同也输出YES ...

  8. Codeforces Round #620 (Div. 2)D(LIS,构造)

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; ]; int main(){ io ...

  9. Codeforces Round #620 (Div. 2) E

    LCA的倍增 模板: ], depth[maxn]; int dist[maxn],head[maxn]; void add(int u,int v,int dist0){ a[tot].next=h ...

随机推荐

  1. Verilog 编写规范

    在学习Python时,作者有一句话对我影响很大.作者希望我们在学习编写程序的时候注意一些业内约定的规范.在内行人眼中,你的编写格式,就已经暴露了你的程度.学习verilog也是一样的道理,一段好的ve ...

  2. active Directory域服务安装配置

    1.在Windows功能启用 2.安装一直下一步即可, 添加用户 添加域管理员 将普通用户添加到Domain Admins里

  3. 动态路由协议 RIP

    RIP:Routing Information Protocol.RFC1058. 距离矢量协议:有间隔的多少和方向.传递的是路由条目.每个路由器不知道网络的完整拓扑结构,OSPF知道. 度量值:每种 ...

  4. ToolStripComboBox的DataSource和DataTable使用技巧

      可以使用Items属性private void GetData() //一下数据均为测试{toolStripComboBox1.Items.Clear();            DataTabl ...

  5. AcWing 840. 模拟散列表

    拉链法 #include<cstring> #include<iostream> using namespace std ; ; int h[N],e[N],ne[N],idx ...

  6. java项目上有个红色感叹号(在project Explorer视图下)

    启动项目时一直报错,检查也没问题,最后看到项目上有个红色感叹号,发现是jar包路径不对,把错误路径的jar包移除,然后再重新添加即可.

  7. MySQL 学习(二)总体框架 & redo-log 和 bin-log 的介绍

    文章部分总结来自课程,非原创 MySQL 组织架构     下面这张图就可以解释关于 MySQL 底层的组织架构了.     上面的图可以直观地展示两个重要的东西 : 一条 SQL 的执行流程 MyS ...

  8. 删除文件时提示,你需来自SYSTEM的权限

    1. 提示如下 2. 对要删除的文件操作如下 2.1 为删除的文件添加本地账户 2.2 提示如下,多点几次继续就好 2.3 给本地账户添加完全控制权限

  9. Win10安装.Net Framework4.7及更高版本

    问题描述 使用VS打开项目工程时,提示未安装.net framework4.7,但在启用或关闭windows功能里已经勾选了.net framework 4.7的全部功能. 直接从网上下载.net f ...

  10. php从接口获取数据转成可以用的数组或其他(含转换编码)

    程序开发,时常会用到将接口的json数据转换成程序可以用的,因为今天看到一个比较好的程序,贴上来,以备随时查看: /** * 将对象转成数组,并按要求转换编码 * * @param array $ar ...