#include using namespace std; using ll=long long; ll counting_primes(ll x){ if(x<=70){ vector p_table(x+1,1); p_table[0]=0; p_table[1]=0; for(int i=2;i*i<=x;i++){ if(p_table[i]==0){ continue; } for(int j=2;i*j<=x;j++){ p_table[i*j]=0; } } ll ret=0; for(int i=1;i<=x;i++){ if(p_table[i]){ ret++; } } return ret; } //P2(x,a)を計算 ll N=1; while((N+1)*(N+1)*(N+1)<=x){ N++; } ll NN=(ll)pow(x,2.0/3.0);//誤差が怖い vector p_table(N+1,1); vector P; p_table[0]=0; p_table[1]=0; for(ll i=2;i*i<=N;i++){ if(p_table[i]==1){ for(ll j=2;i*j<=N;j++){ p_table[i*j]=0; } } } for(ll i=1;i<=N;i++){ if(p_table[i]==1){ P.push_back(i); } } int n=P.size(); ll pi1=(ll)n; vector cnt(N+1); ll pi2=-1; ll x_half=1; while((x_half+1)*(x_half+1)<=x){ x_half++; } ll S=0; for(ll j=2;(j-1)*N+1<=NN;j++){ for(int i=1;i<=N;i++){ p_table[i]=1; } for(int i=0;i(x/(min(j*N+1,NN+1)),N); ll right=min(x/((j-1)*N+1),x_half); if(left I(right-left+1,1); I[0]=0; for(int i=0;i(NN,j*N)-(j-1)*N]; } S+=(ll)n*((ll)n-1)/2; S-=pi2*(pi2-1)/2; //phi(x,a)の計算 //S1 ll S1=0; vector mu(N+1,1); mu[0]=0; for(int i=0;i f(N+1,0); f[1]=x; for(int i=0;i0;i++,tmp_N>>=1){ m++; } vector phi(n+1,0); for(ll k=1;(k-1)*N+1<=NN;k++){ vector> a(m+1,vector(N+2,0)); for(int i=0;i<=m;i++){ for(ll j=1;j<=(N/(1LL<(1LL<(k*N,NN)-(k-1)*N-(j-1)*(1LL<(0,x/((min(k*N,NN)+1)*P[b])); ll right=min(N,x/(((k-1)*N+1)*P[b])); for(ll i=left+1;i<=right;i++){ if(f[i]>P[b]&&mu[i]!=0){ ll y=x/(i*P[b]); ll l=y-(k-1)*N; vector e; for(int i=0;l>0;i++,l>>=1){ if((l&1)==1){ e.push_back(i); } } reverse(e.begin(),e.end()); ll sum=phi[b]; for(int r=0;r e; for(int i=0;l>0;i++,l>>=1){ if((l&1)==1){ e.push_back(i); } } reverse(e.begin(),e.end()); for(int r=0;r>L>>R; //cout<