Scalar Product
Time limit3sMemory limit1024 MB
Given integers a, b, and R, find the maximum dot product of (a, b) with an integer point (x, y) satisfying x^2 + y^2 <= R^2.
- Level
Medium7 of 10
- Topics
- Geometry, Math, Number theory
- Solved
- No attempts yet
Problem
Given integers , , and , consider the vector . Find the maximum value of the scalar product over all integer pairs with .
Input
The first line contains one integer , the number of test cases (). Each of the following lines contains three integers , , and (, ).
Output
For each test case, print the maximum scalar product on a separate line.
Hint
In the first test case, there are 13 integer points with . Three of them, , , and , give the maximum scalar product with . For example, .