Scalar Product
시간 제한3초메모리 제한1024 MB
정수 벡터 (a,b)와 반지름 R이 주어질 때, x^2 + y^2 <= R^2인 정수점 (x,y)에서 a*x + b*y의 최댓값을 구한다.
문제
Given vector (where and are integers) and integer . Find the maximum value of the scalar product , where both and are integer, and .
입력
First line of the input contains one integer --- the number of the test cases (). Each of the following lines contains three integers , and (, ).
출력
For each test case, print in the separate string one integer --- the maximal scalar product.
힌트
For the first test case in the sample, we have 13 integer points such as . Between those 13 points we have three points , , with the scalar prodct on reaches the maximum, for example, .