首先可以随便莫反一波,可以得到
由的定义可以得到
其中
后面可以用杜教筛筛一下
#include<bits/stdc++.h>
using namespace std;
const int RLEN=1<<20|1;
inline char gc(){
static char ibuf[RLEN],*ib,*ob;
(ob==ib)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
return (ob==ib)?EOF:*ib++;
}
#define gc getchar
inline int read(){
char ch=gc();
int res=0,f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
#define ll long long
#define re register
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define cs const
#define bg begin
#define uint unsigned int
inline void chemx(int &a,int b){a<b?a=b:0;}
inline void chemn(int &a,int b){a>b?a=b:0;}
inline uint ksm(uint x,int b){
uint res=1;
for(;b;b>>=1,x=x*x)if(b&1)res=res*x;
return res;
}
cs int N=50004;
int n,k;
namespace F{
uint f1[N],f2[N],pt[N];
int lim,pr[N],tot;
inline void init(int n){
lim=sqrt(n),tot=0;
for(int i=1;i<=lim;i++)f1[i]=i-1,f2[i]=n/i-1;
for(int p=2;p<=lim;p++){
if(f1[p]==f1[p-1])continue;
pr[++tot]=p;
for(int i=1;i<=lim/p;i++)f2[i]-=(f2[i*p]-f1[p-1]);
for(int i=lim/p+1;1ll*i*p*p<=n&&i<=lim;i++)f2[i]-=(f1[n/i/p]-f1[p-1]);
for(int i=lim;i>=1ll*p*p;i--)f1[i]-=(f1[i/p]-f1[p-1]);
}
for(int i=1;i<=tot;i++)pt[i]=ksm(pr[i],k);
}
inline uint F(int x){
return x>lim?f2[n/x]:f1[x];
}
unordered_map<int,uint> mp[N];
inline uint sieve(int res,int pos){
if(mp[pos].count(res))return mp[pos][res];
uint anc=0;
if(res<pr[pos])return 0;
for(int i=pos;i<=tot;i++){
if(1ll*pr[i]*pr[i]>res)break;
for(ll now=pr[i],xs=1;now<=res;now*=pr[i],xs++)
if(1ll*now*pr[i]<=res)anc+=sieve(res/now,i+1),anc+=pt[i]*(F(res/now)-i+1);
}
return mp[pos][res]=anc;
}
inline uint query(int x){
return sieve(x,1)+F(x);
}
}
cs int mod=19260817;
struct Map{
int key[mod];uint val[mod];
Map(){memset(key,-1,sizeof(key));}
int posit(int x)cs{
int h=x%mod;
while(key[h]!=-1&&key[h]!=x)h=h==mod-1?0:h+1;
return h;
}
uint &operator[](int x){
int p=posit(x);
if(key[p]==-1){
key[p]=x,val[p]=0;
}
return val[p];
}
inline bool count(int x)cs{return key[posit(x)]==x;}
};
namespace G{
cs int N=2000006;
Map mp;
uint phi[N],pr[N],tot,vis[N];
inline void init(){
cs int len=N-6;
phi[1]=1;
for(int i=2;i<=len;i++){
if(!vis[i])pr[++tot]=i,phi[i]=i-1;
for(int j=1;j<=tot&&i*pr[j]<=len;j++){
vis[i*pr[j]]=1;
if(i%pr[j]==0){phi[i*pr[j]]=phi[i]*pr[j];break;}
phi[i*pr[j]]=phi[i]*phi[pr[j]];
}
}
for(int i=1;i<=len;i++)phi[i]+=phi[i-1];
}
inline uint S(uint x){
return (uint)(1ll*x*(x+1)/2);
}
inline uint query(int x){
if(x<=N-6)return phi[x];
if(mp.count(x))return mp[x];
uint res=S(x);
for(int i=2,nxt;i<=x;i=nxt+1){
nxt=x/(x/i);
res-=(nxt-i+1)*query(x/i);
}
return mp[x]=res;
}
}
uint res=0;
int main(){
n=read(),k=read();
F::init(n);G::init();
for(int i=1,nxt;i<=n;i=nxt+1){
nxt=n/(n/i);
uint a=G::query(n/i)*2-1,b=(F::query(nxt)-F::query(i-1));
res+=a*b;
}
cout<<res;
}