Description
Today's math class, crash children learn least common multiple (Least Common multiple). For two positive integers a and B,LCM (A, b) represent the smallest positive integers that can be divisible by A and b at the same time. For example, the LCM (6, 8) = 24. Back home, crash still thinking about class school, in order to study least common multiple, he drew a n*m form. A number is written in each lattice, where the lattice in column J of Row I is written in the LCM (i, J). A 4*5 table is as follows: 1 2 3 4 5 2 2 6 4 10 3 6 3 12 15 4 4 12 4 20 Looking at this form, crash thought of a lot of things to think about. But the question he most wants to solve is a very simple question: how much is there in this table? When N and M are big, crash is helpless, so he finds the smart you use the program to help him solve the problem. Since the end result can be large, crash only wants to know the values of all the numbers in the table and mod 20101009.
Input
The first line of input contains two positive integers, representing N and M., respectively.
Output
Outputs a positive integer that represents the number of values in the table and mod 20101009.
Sample Input4 5
Sample Output122MO anti-hard onRecommendedPOPOQQQ Courseware ... The last fragment processing part to maintain the prefix of i^2*μ (i)
#include <cstdio>#include<algorithm>#definell Long Long#defineN 10000000using namespacestd;intRead_p,read_ca;inlineintRead () {read_p=0; read_ca=GetChar (); while(read_ca<'0'|| Read_ca>'9') read_ca=GetChar (); while(read_ca>='0'&&read_ca<='9') read_p=read_p*Ten+read_ca- -, read_ca=GetChar (); returnread_p;}Const intMod=20101009;intn,m,t,mu[n+1],p[n],num=0, Mmh,ni,mi;BOOLbo[n+1];inlineintFintx) {return1ll*x* (x+1)/2%MOD;} InlineintMinintAintb) {returnA<b?a:b;} InlineintMintx) { while(X>=mod) X-=mod; while(x<0) X+=mod;returnx;} InlineintMMH (intNintm) { intMmh=0; for(RegisterintI=1, j=0; i<=n;j=i++) I=min (n/(ni=n/i), m/(mi=m/i)), mmh= (1ll*f (NI) *f (mi)%mod*m (mu[i]-mu[j]) +mmh)%MOD; returnmmh;}intMain () {n=read (); m=read (); if(n>m) swap (N,M); Registerinti,j; mu[1]=1; for(i=2; i<=m;i++){ if(!bo[i]) p[++num]=i,mu[i]=-1; for(j=1; j<=num&&p[j]*i<=m;j++) {Bo[i*p[j]]=1; if(I%p[j]) mu[i*p[j]]=-mu[i];Else{mu[i*p[j]]=0; Break; } } } for(i=1; i<=m;i++) Mu[i]=m (1ll*mu[i]*i*i%mod+mu[i-1]); for(intI=1, j=0; i<=n;j=i++) I=min (n/(n/i), m/(m/i)), mmh= (1ll*m (f (i)-f (j)) *mmh (n/i,m/i) +mmh)%MOD; printf ("%d\n", MMH);}
88696 KB 4848 ms C++/edit 1326 B
Bzoj:2154:crash's Digital table