Streets Behind
시간 제한1초메모리 제한2048 MB
각 훈련에서 진지한 선수 비율 x/(x+y)가 a/b 이상이면 모든 캐주얼 선수가 진지한 선수로 바뀔 때, 전원을 바꾸는 최소 훈련 횟수를 구하거나 불가능하면 -1을 출력한다.
문제
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 serious runners and casual runners in a training run, if is greater than or equal to a threshold , then after the run, all 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 (). This is the number of test cases.
Each of the next lines contains a test case. Each test case consists of four integers , , , ( and ), where is the number of serious runners, is the number of casual runners, and is the threshold which converts casual runners to serious runners.
출력
Output 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 for that test case.