您的位置:首页 > 其它

UVa OJ 10994-Simple Addition

2011-01-30 23:09 211 查看
纯数学题,搞了好久:

{
Author:wzx961008
Problem:UVa 10994-Simple Addition
Verdict:Accepted
Language:PASCAL
Run Time:0.028s
Submission Date:2011-01-30 15:00:23
}
var p,q:longint;
function f(n:int64):int64;
var ans:int64;
i:longint;
begin
if n<=0 then exit(0);
ans:=0;
while n<>0 do begin
inc(ans,(n div 10)*45);
for i:=(n div 10)*10+1 to n do inc(ans,i mod 10);
n:=n div 10;
end;
exit(ans);
end;
begin
while true do begin
readln(p,q);
if (p=-1)and(q=-1) then break;
writeln(f(q)-f(p-1));
end;
end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: