We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<bits/stdc++.h>#define ll long long#define mod 30000001#define L 110#define N 10000010llipow(llb,lle){if(e==0)return1;if(e==1)returnb;if(e&1)returnipow(b,e-1)*b%mod;returnipow(b*b%mod,e>>1);}llinv[L+2];llA[L+1];llB[L+1];llC[L+1][L+1];llP[L+1];llG[N+1];intmain(){inv[0]=inv[1]=1;for(inti=2;i<=L+1;i++){inv[i]=(mod-mod/i)*inv[mod%i]%mod;}for(inti=0;i<=L;i++){for(intm=0;m<=i;m++){A[m]=inv[m+1];for(intj=m;j;j--){A[j-1]=j*(A[j-1]-A[j])%mod;}}B[i]=A[0];}G[0]=0;for(intn=0;n<=L;n++){for(intr=0;r<=L;r++){if(r>n){C[n][r]=0;}elseif(r==0orr==n){C[n][r]=1;}else{C[n][r]=(C[n-1][r-1]+C[n-1][r])%mod;}}}intz;scanf("%d",&z);while(z--){intn,d;scanf("%d%d",&n,&d);intc=int(fmin(n,pow(n,2./3)*pow(log(n+1),1./3)*2))+1;for(inti=1;i<c;i++){G[i]=ipow(i,d)-ipow(i-1,d);}for(inti=1;i<c;i++){G[i]%=mod;for(intj=i<<1;j<c;j+=i){G[j]-=G[i];}G[i]+=G[i-1];G[i]%=mod;}for(intk=n/c;k;k--){inti=n/k;intu=int(sqrt(i))+1;llt=ipow(i,d);for(intg=i/u;g>1;g--){t-=G[i/g];}t%=mod;for(intv=1;v<u;v++){t-=(i/v)*(G[v]-G[v-1]);t%=mod;}t+=(i/u)*G[u-1];G[i]=t%mod;}intq;scanf("%d",&q);while(q--){intl;scanf("%d",&l);llt;if(l==0){t=ipow(n,d);}else{for(intk=0;k<=l;k++){P[k]=C[l+1][k]*B[k]%mod;}llres;#define set_F(_w) do {\ ll w = (_w);\ res = 0;\ for(int k = 0; k <= l; k++){\ res += P[k];\ res *= w;\ res %= mod;\ }\ } while(0)intu=int(sqrt(n/l))+1;t=0;for(intv=1;v<u;v++){set_F(n/v);t+=res*(G[v]-G[v-1]);t%=mod;}set_F(n/u);t-=res*G[u-1];t%=mod;t*=inv[l+1];t%=mod;for(intg=n/u;g;g--){t+=ipow(g,l)*G[n/g];t%=mod;}}if(t<0)t+=mod;printf("%lld\n",t);}}}
C++ solution
can anyone tell me solution
I read the editorial, but It seems that none of the formulas in it are printed by my browser, thus the editorial is of no use to me. Hom comes ?