Description The input file contains multiple sets of test data.
The first line, an integer t, represents the number of groups of test data.
Next T line, two integers per line n, M. outputt lines, one integer per line, represents the answer you ask for. Sample Input
2
7 4
5 6
Sample Output
110
121
Data Constraint
Solution: The inverse of the Mo, said SD last year seems to have a problem inverse problem
Sticking to the blog of the Great God
http://blog.codebursts.com/bzoj3994/
#include <cstdio>#include<cstdlib>#include<algorithm>#include<cmath>#include<cstring>using namespaceStd;typedefLong Longll;ll num[50011],mu[50011],ans;intpri[50011],np[50011];BOOLp[50011];intdt,tj,i,j,n,m;voidPrepare () {ll tz; intI,j,lim,tot; Lim=50000; Tot=0; Memset (P,true,sizeof(p)); num[1]=1; mu[1]=1; for(i=2; i<=lim;i++){ if(P[i]) {pri[++tot]=i; Num[i]=2; Np[i]=1; Mu[i]=-1; } for(j=1; j<=tot;j++) {TZ= (LL) pri[j]*i; if(Tz>lim) Break; P[PRI[J]*i]=false; if(i%pri[j]==0) {Np[pri[j]*i]=np[i]+1; NUM[PRI[J]*i]=num[i]/(np[i]+1) * (np[i]+2); MU[PRI[J]*i]=0; Break; } Np[pri[j]*i]=1; NUM[PRI[J]*i]=num[i]*2; MU[PRI[J]*i]=-Mu[i]; } } for(i=1; i<=lim;i++) {Num[i]+=num[i-1]; Mu[i]+=mu[i-1]; }}intMain () {scanf ("%d",&DT); Prepare (); for(tj=1; tj<=dt;tj++) {scanf ("%d%d",&n,&m); if(n>m) swap (N,M); Ans=0; for(i=1, j;i<=n;i=j+1) {J=min (n/(n/i), m/(m/i)); Ans+=1ll*num[n/i]*num[m/i]* (mu[j]-mu[i-1]); } printf ("%lld\n", ans); }}
SDOI2015 about a few numbers and