#K59592. Perfect Squares in a Range
Perfect Squares in a Range
Perfect Squares in a Range
Given two integers (L) and (R), determine the number of perfect squares in the inclusive range [(L), (R)] and find the largest perfect square within this interval. A perfect square is an integer that is the square of an integer. If no perfect square exists in the interval, output the count as 0 and the largest value as -1. Use the formulas (start = \lceil \sqrt{L} \rceil) and (end = \lfloor \sqrt{R} \rfloor). Then, if (end \geq start), the count is (end - start + 1) and the largest perfect square is (end^2); otherwise, the answer is 0 and -1.
inputFormat
The input consists of two space-separated integers (L) and (R) ((1 \leq L \leq R \leq 10^{18})).
outputFormat
Output two space-separated integers: the number of perfect squares in the range and the largest perfect square found. If none exist, output -1 for the largest perfect square.## sample
1 100
10 100