Streets Behind

시간 제한1초메모리 제한2048 MB

요약
각 훈련에서 진지한 선수 비율 x/(x+y)가 a/b 이상이면 모든 캐주얼 선수가 진지한 선수로 바뀔 때, 전원을 바꾸는 최소 훈련 횟수를 구하거나 불가능하면 -1을 출력한다.
난이도

보통10점 중 5점

유형
수학, 그리디
정답자
아직 제출이 없습니다

문제

Your running club has some serious runners and some casual runners. You schedule several training runs with a mixture of serious runners and casual runners. Serious runners run at a faster pace than casual runners, and will leave them behind.

You want all the runners to become serious runners, so when you schedule training runs, you carefully choose the number of serious and casual runners who will participate. You know that when there are xx serious runners and yy casual runners in a training run, if xx+y\frac{x}{x+y} is greater than or equal to a threshold ab\frac{a}{b}, then after the run, all yy casual runners, feeling the pressure to keep up with the serious runners become serious runners moving forward.

Compute the minimum number of training runs you need to convert all members of the club into serious runners.

입력

The first line of input contains a single integer tt (1≤t≤1001\leq t \leq 100). This is the number of test cases.

Each of the next tt lines contains a test case. Each test case consists of four integers nn, kk, aa, bb (1≤n,k,a,b≤1091 \leq n, k, a, b \leq 10^{9} and a≤ba \leq b), where nn is the number of serious runners, kk is the number of casual runners, and ab\frac{a}{b} is the threshold which converts casual runners to serious runners.

출력

Output tt lines, each containing a single integer. For each test case, output the minimum number of training runs needed to convert all casual runners to serious runners. If it is impossible to convert all casual runners to serious runners, output −1-1 for that test case.

예제1

  1. 예제 1

    입력
    3
    9 5 5 6
    2 7 1 8
    3 4 1 5
    
    예상 출력
    3
    1
    1