Title Description
Phoebus likes least common multiple very much, one day he thought of a topic about least common multiple.
The number pair \ ((b) \) logarithm that satisfies the following conditions:\ (a,b\) is a positive integer and \ (A,b\leq n\) and \ (LCM (A, b) >n\). The \ (lcm\) Of course means least common multiple. Answer to \ (1000000007\) modulo.
Input
The first line is a positive integer \ (n\).
Output
An integer on one line represents the answer, modulo \ (1000000007\) .
Example Sample input
3
Sample output
2
Data range
\ (N\leq 10^{10}\)
Exercises
God, the difficulty is very\ (NOIp (rofessional) \)。
First of all, considering the greater than the bad, obviously less than equals better, we use the complement method to find out\ (lcm\)Less than or equal\ (n\), and then the total programme number is poor.
\[\sum_{i=1}^n\sum_{j=1}^n LCM (i,j) \leq n\]
\[\sum_{i=1}^n\sum_{j=1}^n \frac{i\cdot j}{gcd (i,j)}\leq n\]
Now follow the routines, change the enumeration\ (D=GCD (i,j) \)Give it a try
\[\sum_{d=1}^n\sum_{i=1}^{n}\sum_{j=1}^{n}[gcd (i,j) =d]\&[\frac{i\cdot J}{d}\leq n]\]
\[\sum_{d=1}^n\sum_{i ' =1}^{\frac{n}{d}}\sum_{j ' =1}^{\frac{n}{i ' \cdot d}}[gcd (i ', J ') =1]\]
The Möbius function can be played!
\[\sum_{d=1}^n\sum_{i ' =1}^{\frac{n}{d}}\sum_{j ' =1}^{\frac{n}{i ' \cdot d}}\mu (gcd (i ', j ')) \]
Re-swap Enumeration\ (d ' =gcd (i ', j ') \)。
\[\sum_{d=1}^n\sum_{d ' =1}^{\sqrt{\frac{n}{d}}}\mu (d ') \times[i ' \cdot J ' \leq \frac{n}{d ' ^2\cdot D} group number]\]
Well...... We put\ (d ' \)Put it on the outermost. Because\ (d\times d ' ^2\leq n\), so you can find\ (d ' \)No more than\ (\sqrt{n}\)。
\[\sum_{d ' =1}^{\sqrt{n}}\mu (d ') \times[d\cdot i ' \cdot J ' \leq \frac{n}{d ' ^2} group number]\]
All right, we only ask for the number of triples! Can make\ (d ' \leq i ' \leq J ' \), then arrange the combined calculation ...
And if you specify the order of size, you can save time. For example, the first number is raised to three times the root is stopped, the second number is enumerated to the remaining square root is stopped, the last number can be calculated directly.
This complexity can be proved to be \ (O (n^{\frac{2}{3}) \) , while the Du sieve can achieve the same complexity, but there will be a greater constant.
\ (code:\)
#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include < algorithm>using namespace std; #define N 100005#define ll long long#define mod 1000000007template<typename mytype& Gt;void Read (Mytype &p) {p = 0; char C = GetChar (); for (; c < ' 0 ' | | c > ' 9 '; c = GetChar ()); for (; c >= ' 0 ' && C <= ' 9 '; c = GetChar ()) p = p * + C-' 0 ';} ll N;int Mu[n], h[n], P[n], Cnt;int main () {Read (n); MU[1] = 1; for (int i = 2; I <= N-5; i++) {if (!h[i]) {p[++cnt] = i; Mu[i] =-1; } for (int j = 1; J <= CNT; j + +) {if (i * p[j] > N-5) break; H[i * P[j]] = 1; if (i% p[j] = = 0) {Mu[i * p[j]] = 0; Break } Mu[i * P[j]] =-mu[i]; }} int m = int (sqrt (n) + 0.5), ans = 0; for (int i = 1; I <= m; i++) { ll w = n/i/I, sum = 0; for (ll a = 1, a * A * a <= w; a++) {for (ll B = A; b * b <= w/a; b++) { ll C = w/a/B-b + 1; if (a = = b) sum = (sum + 1 + (c-1) * 3)% MoD; else sum = (sum + 3 + (c-1) * 6)% MoD; }} sum%= mod; Ans = (ans + mu[i] * sum)% mod; } ans =-ans; Ans = (ans + (n MoD) * (n MoD))% MoD; if (ans < 0) ans + = mod; printf ("%d\n", ans);}
Simulated 20181010"sun god Möbius inversion