P18287 [HackerRank] Arthur and coprimes
普及
题目描述

Arthur defines a function, $f(k)$, to be the number of $(p,q)$ pairs such that:

$1<p\leq q\leq k$
${p}$ and $q}$ are coprime.
$p\cdot q=k$

Given an integer, $n$, help Arthur find and print the result of:
$\sum_{k=1}^{n}f(k)$

Input Format

The first line contains a single integer denoting $n$.

Constraints

$1\leq n\leq10^9$

Subtasks

$1\leq n\leq150$ for $30\%$ of the maximum score.
$1\leq n\leq10^{6}$ for ${60%}$ of the maximum score.

Output Format

Print the result of $\textstyle\sum_{k=1}^{n}f(k)$ on a new line.

Sample Input
12

Sample Output
3

Explanation

The value of $f(k)$ for $1\leq k\leq12$ is:

For $k=6$, there is only $\mbox{I}$ valid pair, $(2,3)$, so $f(6)=1$.
For $k=10$, there is only $\mbox{I}$ valid pair, $(2,5)$, so $f(10)=1$
For $k=12$, there is only $\mbox{I}$ valid pair, $(3,4)$, so $f(12)=1$
For all other $1\leq k\leq12$, the function returns $\mbox{0}$.

Thus, our final sum is the result of $1+1+1=3$.

输入格式

见题面

输出格式

见题面

样例输入
12
样例输出
3