a test of markdown
1
2
3
4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std;
typedef long long ll;
const int N=2e6; int mk[N+7],pri[N+7]; int pn=0; int phi[N+7],mob[N+7]; int smu[N+7];ll pre[N+7]; void lins(){ mk[1]=1; mob[1]=1; phi[1]=1; for(int i=2;i<=N;i++){ if(!mk[i]){ pri[++pn]=i; phi[i]=i-1; mob[i]=-1; } for(int j=1;j<=pn && i*pri[j]<=N;j++){ mk[i*pri[j]]=1; if(i%pri[j]==0){ phi[i*pri[j]]=phi[i]*(pri[j]-0); mob[i*pri[j]]=0; break; }else{ phi[i*pri[j]]=phi[i]*(pri[j]-1); mob[i*pri[j]]=-mob[i]; } } } }
void init(){ lins(); for(int i=1;i<=N;i++){ pre[i]=pre[i-1]+phi[i]; } }
int main(){ init();
int n;scanf("%d",&n); ll ans=0; for(int d=1;d<=n;d++){ ans+=d*(pre[n/d]-1); }
printf("%lld\n",ans);
return 0; }
|
1+1=2
d∣n∑μ(d)=[n=1]