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. 解决:配置虚拟主机,重启apache,[warn] _default_ VirtualHost overlap on port 80, the first has precedence

    http://blog.csdn.net/kaizhu_qin/article/details/17506293 很多第一次配置apache的虚拟主机的时候,以为配置第一个虚拟主机完成以后,以后就不会 ...

  2. HTML学习(13)区块元素和内联元素

    HTML 区块元素 大多数 HTML 元素被定义为块级元素或内联元素. 块级元素在浏览器显示时,通常会以新行来开始(和结束). 实例: <h1>, <p>, <ul> ...

  3. 牛客1080D tokitsukaze and Event (双向最短路)

    题目链接:https://ac.nowcoder.com/acm/contest/1080/D 首先建两个图,一个是权值为a的图,一个是权值为b的图. 从s起点以spfa算法跑权值为ai的最短路到t点 ...

  4. 在mac上进行JAVA开发

    一.  JDK 的下载与安装 终端输入java看看有没有安装java: 见到此弹窗,说明没有安装呀! 点击oracle官网链接: http://www.oracle.com/technetwork/j ...

  5. sqli-libs(38-41(堆叠注入)关)

    补充知识:堆叠注入(Stacked injections) 从名词的含义就可以看到应该是一堆sql语句(多条)一起执行.而在真实的运用中也是这样的,我们知道在mysql中,主要是命令行中,每一条语句结 ...

  6. 2019南昌网络赛 hello 2019

    这道题和一道2017,2016的类似. A string t is called nice if a string “2017” occurs in t as a subsequence but a ...

  7. 一个超几何函数$_3F_2$的积分

    \[\Large\displaystyle \int_0^\infty{_3F_2}\left(\begin{array}c\dfrac58,\dfrac58,\dfrac98\\\dfrac12,\ ...

  8. Bug搬运工-CSCux99539:Intermittent error message "Power supply 2 failed or shutdown"

    Description Symptom:Following error messages will be seen intermittently.%PFMA-2-PS_FAIL: Power supp ...

  9. java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory解决方法

    解决方法 第一种方法:导入commons-logging.jar包 第二种方法,如果用的是maven项目,则直接在pom.xml中加入commons-logging依赖包,如下: <depend ...

  10. 每日扫盲(四):java之Netty原理和使用

    转自:https://www.jdon.com/concurrent/netty.html Netty是一个高性能 事件驱动的异步的非堵塞的IO(NIO)框架,用于建立TCP等底层的连接,基于Nett ...