【模板】Min_25筛
浓缩后的效果
void getpri(int fl[],int fh[],int sp[],long long n,int h,int t,int(*g)(unsigned long long),int(*sumg)(unsigned long long)){
sp[0]=0;
for(int i=1;i<=h;i++)fl[i]=sumg(i)+inf-1,fl[i]-=fl[i]>=inf?inf:0;
for(int i=1;i<=t;i++)fh[i]=sumg(n/i)+inf-1,fh[i]-=fh[i]>=inf?inf:0;
for(int j=1;1ull*p[j]*p[j]<=n;j++)sp[j]=sp[j-1]+g(p[j]),sp[j]-=sp[j]>=inf?inf:0;
for(int j=1;1ull*p[j]*p[j]<=n;j++){
register unsigned long long minv=1ull*p[j]*p[j],gv=inf-g(p[j]);
for(register int i=1;i<=t&&n>=minv*i;i++)
fh[i]=(gv*((1ull*p[j]*i>t?fl[n/(1ull*p[j]*i)]:fh[i*p[j]])+inf-sp[j-1])+fh[i])%inf;
for(register int i=h;i>=1&&i>=minv;i--)
fl[i]=(gv*(fl[i/p[j]]+inf-sp[j-1])+fl[i])%inf;
}
}
int g1[1000002],g2[1000002],s[1000002],len1,len2;
long long n,cntt=0;
inline int f(int p,int c){return 1;}
int get(long long m,int id){
register int ans;
ans=m<=len1?g1[m]:g2[n/m];
for(register int j=id;1ull*p[j]*p[j]<=m;j++)
for(register long long i=1,v=p[j];v*p[j]<=m;i++,v=v*p[j])
ans=(1ull*f(p[j],i)*(get(m/v,j+1)+inf-s[j])+f(p[j],i+1)+ans)%inf;
return ans;
}
Please not contact lydsy2012@163.com!