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. jenkins pipline 几个注意细节

    新建jenkins pipline 1)pipeline的脚本语法要正确,sonarqube的projectKey需要做相应的修改 2)先执行一次构建,会报错 3)进到jenkins workspac ...

  2. MongoDB 在Windows环境的下载、安装、配置

    MongoDB4.0在Windows环境的下载.安装.配置 今天本想玩玩MongoDB,可因工作机上未下载Linux虚拟机,下载多耗时.无奈只能先下载Windows版本耍耍.不料,Windows在安装 ...

  3. OSI七层协议详解

    一.简介 开放系统互连参考模型 (Open System Interconnect 简称OSI)是国际标准化组织(ISO)和国际电报电话咨询委员会(CCITT)联合制定的开放系统互连参考模型,为开放式 ...

  4. 解决async 运行多线程时报错RuntimeError: There is no current event loop in thread 'Thread-2'

    原来使用: loop = asyncio.get_event_loop()task = asyncio.ensure_future(do_work(checker))loop.run_until_co ...

  5. 微信小程序实例test

    index.js //index.js //获取应用实例 const app = getApp() var pageConfig = { data: { motto: 'Hello World', u ...

  6. [Java] 多线程基础详细总结,附加详细实例

    详细代码在文章底部 目录 基础概念 进程与线程 单线程与多线程 实现线程的4中方式 thread.start()和runnable.run()的区别 Thread和Runnable的异同 线程的基本操 ...

  7. Docker - 命令 - docker volume

    概述 docker volume 命令 背景 docker 容器的存储, 通常需要独立于镜像 docker volume 就是负责这块的命令 1. 写在 docker volume 之前 概述 doc ...

  8. TCL Strings

    append    Append values to variable binary      Insert and extract fields from binary strings regexp ...

  9. python进阶(十七)xml(下)

    1.XML简介 xml用到的地方:tomcat配置文件 1) xml 指可扩展标记语言(Extensible Markup Language) 2) xml 被设计用于结构化.存储和传输数据 3) x ...

  10. 种树-洛谷P1250(差分约束)

    传送门 令前缀和为s[i],则⼀一个要求等价于 s[r] - s[l - 1] >= x. 题中还有别的要求,包括 s[i] - s[i - 1] <= 1 和 s[i] - s[i- 1 ...