Logo
(追記) (追記ここまで)

24831번 - Two Rabbits 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 256 MB27622719481.513%

문제

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 $x,ドル and the shorter rabbit is currently on position $y$ ($x \lt y$). Every second, each rabbit hops to another position. The taller rabbit hops to the positive direction by $a,ドル and the shorter rabbit hops to the negative direction by $b$.

For example, let's say $x=0,ドル $y=10,ドル $a=2,ドル and $b=3$. At the 1ドル$-st second, each rabbit will be at position 2ドル$ and 7ドル$. At the 2ドル$-nd second, both rabbits will be at position 4ドル$.

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.

입력

Each test contains one or more test cases. The first line contains the number of test cases $t$ (1ドル \le t \le 1000$).

Each test case contains exactly one line. The line consists of four integers $x,ドル $y,ドル $a,ドル $b$ (0ドル \le x \lt y \le 10^9,ドル 1ドル \le a,b \le 10^9$) — 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.

출력

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

5
0 10 2 3
0 10 3 3
900000000 1000000000 1 9999999
1 2 1 1
1 3 1 1

예제 출력 1

2
-1
10
-1
1

노트

The first case is explained in the description.

In the second case, each rabbit will be at position 3ドル$ and 7ドル$ respectively at the 1ドル$-st second. But in the 2ドル$-nd second they will be at 6ドル$ and 4ドル$ respectively, and we can see that they will never be at the same position since the distance between the two rabbits will only increase afterward.

출처

Contest > Codeforces > Codeforces Round 620 (Div. 2) A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /