luogu#P4844. LJJ爱数数

LJJ爱数数

Background

For the solution, please see https://www.cnblogs.com/Blog-of-Eden/p/9367521.html

Problem Description

Once when reading a magazine, PJY saw a problem:

Find all positive integer triples (a,b,c)(a,b,c) such that a,b,cna,b,c \leq n, the greatest common divisor of the three numbers a,b,c\bold{a,b,c} is 1\bold{1}, and 1a+1b=1c\bold{\frac{1}{a}+\frac{1}{b}=\frac{1}{c}}.

PJY thought this problem was too easy, so he threw it to LJJ, who loves counting, and added the Constraints n1012\bold{n \leq 10^{12}}, asking LJJ to count how many triples (a,b,c)\bold{(a,b,c)} satisfy the conditions
(note that when aba \not= b, (a,b,c)(a,b,c) and (b,a,c)(b,a,c) are different triples and should be counted twice).

Halfway through counting, LJJ found that the number was too large, so he passed the problem to you. Please output this number.

Input Format

Only one line: a positive integer n(n1012)n(n\leq 10^{12})

Output Format

Only one line: an integer, representing the number of triples (a,b,c)(a,b,c) that satisfy the conditions.

10
3
100
43
100000
42139

Hint

For 20%20\% of the testdata, n2×103n \leq 2 \times 10^{3}

For 40%40\% of the testdata, n105n \leq 10^{5}

For 60%60\% of the testdata, n107n \leq 10^{7}

For 80%80\% of the testdata, n109n \leq 10^{9}

For 100%100\% of the testdata, n1012n \leq 10^{12}

Translated by ChatGPT 5