标签:
对于100%的数据满足0 < A, B < 10^ 6
题解:基本上同BZOJ2301,就是大大弱化了= =
1 /************************************************************** 2 Problem: 2045 3 User: HansBug 4 Language: Pascal 5 Result: Accepted 6 Time:1448 ms 7 Memory:11944 kb 8 ****************************************************************/ 9 10 const maxn=1500000; 11 var 12 i,j,k,l,m,n,x1,y1,x2,y2,z:longint; 13 a,b:array[0..maxn] of longint; 14 procedure swap(var x,y:longint); 15 var z:longint; 16 begin 17 z:=x;x:=y;y:=z; 18 end; 19 function doit(x,y:longint):int64; 20 var i,j,k:longint; 21 begin 22 doit:=0; 23 if x>y then swap(x,y); 24 if x=0 then exit(0); 25 i:=1; 26 while i<=x do 27 begin 28 if (x div (x div i))<(y div (y div i)) then 29 k:=x div (x div i) 30 else k:=y div (y div i); 31 inc(doit,(b[k]-b[i-1])*int64(x div i)*int64(y div i)); 32 i:=k+1; 33 end; 34 end; 35 begin 36 for i:=2 to maxn do 37 begin 38 if a[i]<>0 then continue; 39 for j:=i to maxn div i do a[i*j]:=i; 40 end; 41 b[1]:=1; 42 for i:=2 to maxn do 43 if a[i]=0 then b[i]:=-1 else 44 if ((i div a[i]) mod a[i])=0 then b[i]:=0 else 45 b[i]:=-b[i div a[i]]; 46 for i:=2 to maxn do b[i]:=b[i]+b[i-1]; 47 readln(n,m,l); 48 writeln(doit(n div l,m div l)); 49 readln; 50 end.
标签:
原文地址:http://www.cnblogs.com/HansBug/p/4472307.html