#C7640. Largest Integer Square Root
Largest Integer Square Root
Largest Integer Square Root
Given a non-negative integer N, find the largest integer X such that \(X^2 \leq N\). In other words, you need to compute the floor of the square root of N. For example, if \(N = 17\), then \(X = 4\) because \(4^2 = 16 \leq 17\) and \(5^2 = 25 > 17\).
Your solution should correctly handle the case when \(N = 0\), and be efficient enough to work with large values of N (e.g., up to \(10^9\)).
inputFormat
The input consists of a single non-negative integer N provided via standard input (stdin).
For example:
17
outputFormat
Output the largest integer X satisfying \(X^2 \leq N\> to standard output (stdout).
For example:
4## sample
17
4