Checking for a full square
It’s possible to do a binary search on any ordered list: be it a list of increasing heights, integer numbers, floating-point numbers, etc. It can even be the set of integers , the set of natural numbers , or the set of rational numbers . We would still pick a range of possible solutions and throw away the unnecessary part on each iteration.
Given a positive integer
n, you are asked to check if it’s a full square without using the
The input contains a single integer
n(2 ≤ n ≤ ).
The program should print
nis a full square and
nis a full square ⇒ there is another number
. Therefore, you can try to find
xon an interval [1, 2, …, n].
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB