这题只是统计0出现的个数是POJ2282的简化版,详解参照POJ2282的题解,
注意,这里所统计的个数都是从1开始的出现的,因为最小为0所以如果最小是0的话ans1=-1,
const
num:array[1..12] of int64=(1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000,100000000000);
var
n,m,ans1,ans2 :int64;
x :array[0..20] of longint;
function work(xx:int64):int64;
var
s:string;
i,j,l:longint;
ans:int64;
begin
ans:=0;
str(xx,s);
l:=length(s);
for i:=1 to l do val(s[i],x[i]);
for i:=1 to l do
begin
if (x[i]>0) then inc(ans,num[l-i+1]);
inc(ans,x[i]*((l-i)*num[l-i+1] div 10));
if (x[i]=0) then inc(ans,xx mod num[l-i+1] +1);
end;
for i:=1 to l do dec(ans,num[i]);
exit(ans);
end;
begin
read(n,m);
while (n>=0) do
begin
if n=0 then ans1:=-1 else ans1:=work(n-1);
ans2:=work(m);
writeln(ans2-ans1);
read(n,m);
end;
end.
——by Eirlys