1318. How Many Divisors
Print how many positive integers divide n exactly.
36 -> 9 1 2 3 4 6 9 12 18 36
97 -> 2 1 and itself
1 -> 1 only 1
Testing every number from 1 to n is O(n) and hopeless at n = 10^12.
Divisors come in pairs. If d divides n then so does n / d, and one of the
two is always at or below the square root. So walking d from 1 to the square
root finds every pair, and each one contributes 2.
The exception is a perfect square, where d and n / d are the same number and
must be counted ONCE rather than twice. Miss that and every perfect square comes
out one too high, which is why 49 is in the tests: the answer is 3, not 4.
Write the loop condition as d * d <= n rather than d <= sqrt(n). Floating
point square roots of large integers can land just below the true value and drop
the final divisor.
Constraints - `1 ≤ n ≤ 1000000000000`
Input
One line containing the integer n.
Output
Print how many positive integers divide n exactly.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.