P14226 [GeeksforGeeks] Count odd factors0844
普及-
题目描述

Given an integer N, count the numbers having an odd number of factors from 1 to N (inclusive).

Example 1:
Input:
N = 5
Output:
2
Explanation:
From 1 - 5 only 2 numbers,
1 and 4 are having odd number
of factors.
Example 2:
Input:
N = 1
Output:
1
Explanation:
1 have only 1(odd)
factor
Your Task:
You don't need to read input or print anything. Your task is to complete the function count() which takes an integer N as input parameters and returns an integer, the total count of numbers from 1 to N having an odd number of factors.

Expected Time Complexity: O(sqrt(N))
Expected Space Complexity: O(1)

Constraints:
0 <= N <= 10^{9}

输入格式

见题面

输出格式

见题面

样例输入
N = 5
样例输出
2