题意:不解释
题解:暂时没看懂,应该是板子题
上代码:(别人写的)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,D=1e9+7;
ll n;int sqrt_n;
int m;ll w[N],s0[N],s1[N];int s[N];
inline int pos(const ll &x)//x是第几个[n/m]
{
return x<=sqrt_n?x:m-n/x+1;
}
int pr[20000],pcnt;
int F(const ll &n,int i)
{
if(n<=pr[i])return 0;
int ans=(s[pos(n)]-s[pr[i]])%D;
for(int j=i+1;;++j)
{
ll nn=n/pr[j];
if(nn<pr[j])break;
int e=1;
while(1)
{
ans=(ans+(ll)F(nn,j)*(pr[j]^e)+(pr[j]^(e+1)))%D;
if((nn/=pr[j])<pr[j])break;
++e;
}
}
return ans;
}
int main()
{
cin>>n;
sqrt_n=sqrtl(n);
for(ll i=1;i<=n;i=w[m]+1)
{
++m;
w[m]=n/(n/i);
ll x=w[m]%D;
s0[m]=x-1;
s1[m]=(x*(x+1)/2-1)%D;
}
for(int i=2;i<=sqrt_n;++i)
{
if(s0[i]==s0[i-1])continue;
pr[++pcnt]=i;
ll sqr_i=(ll)i*i;
for(int j=m;w[j]>=sqr_i;--j)
{
s0[j]-=s0[pos(w[j]/i)]-s0[i-1];
s1[j]-=(s1[pos(w[j]/i)]-s1[i-1])*i;
}
}
for(int i=2;i<=m;++i)s[i]=(s1[i]-s0[i]+2)%D;
pr[0]=1;pr[pcnt+1]=sqrt_n+1;
cout<<((F(n,0)+1)%D+D)%D<<endl;
}