
传送门:Codeforces Round 518 (Div. 2) B.LCM
Description
Ivan has number b. He is sorting through the numbers aa from 1 to 10^18, and for every aa writes [a,b]/a on blackboard. Here [a,b] stands for least common multiple of aa and bb. Ivan is very lazy, that’s why this task bored him soon. But he is interested in how many different numbers he would write on the board if he would finish the task. Help him to find the quantity of different numbers he would write on the board.
Input
The only line contains one integer — b (1≤b≤10^10).
Output
Print one number — answer for the problem.
Sample Input
1
Sample Output
1
Sample Input
2
Sample Output
2
Thinking
给出一个数字b,然后求[a,b]/a,的不同取值有多少种,[a,b]值最小公倍数。这里有(a*b)/gcd(a,b) == [a,b]。原式转化为b/gcd(a,b)。当分母gcd(a,b)>b的时候,取值唯一变成0,实际上也永远不可能大于b。因此答案就变成了求b的约数的个数。可以线性遍历求出约数个数,复杂度为O(sqrt(b))。但这里利用唯一分解定理。
Code
1 |
|




近期评论