Problems > Integer Square Root

Integer Square Root

Difficulty: 1200 2000 ms 128 MB

math binary-search

Print ⌊√N⌋, the largest integer whose square does not exceed N.

Input: one integer N.

Output: the integer square root of N.

Constraints:

  • 0 ≤ N ≤ 1018

Sample Tests

Input 1
10
Output 1
3
Input 2
144
Output 2
12

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.