Maximum Sine
Time limit3sMemory limit1024 MB
Given a, b, p, and q, find the smallest integer x in [a, b] that maximizes |sin(p/q * pi * x)| across multiple test cases.
- Level
Medium7 of 10
- Topics
- Math, Number theory
- Solved
- No attempts yet
Problem
You are given integers , , , and . Let . Find the minimum integer that maximizes over all integers with .
Input
The first line contains the number of test cases (). Each test case is on its own line and contains four integers , , , and (, ).
Output
For each test case, print the minimum integer that maximizes , one per line.
Hint
In the first test case, , , and . In the second test case, , which is the largest value among all candidates.