Program FindSumDigit var N1 N2 LongInt LongInt LongInt SN1 SN2 SA0 Dou

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Program FindSumDigit;
var
N1, N2: LongInt;
i, T: LongInt;
X, C: LongInt;
SN1, SN2, SA0: Double;
begin
assign(INPUT,'sumnum.in');reset(INPUT);
assign(OUTPUT,'sumnum.out');rewrite(OUTPUT);
ReadLn(N1, N2);
SA0:= 0;
For i:= 1 to 99999 do begin
T:= i;
While T <> 0 do begin
SA0:= SA0+(T mod 10);
T:= T div 10;
end;
end;
X:= N2;
C:= X div 100000;
SN2:= 0;
For i:= 0 to C-1 do begin
T:= i;
While T <> 0 do begin
SN2:= SN2+(T mod 10);
T:= T div 10;
end;
end;
SN2:= 100000*SN2+C*SA0;
For i:= X-(X mod 100000) to X do begin
T:= i;
While T <> 0 do begin
SN2:= SN2+(T mod 10);
T:= T div 10;
end;
end;
X:= N1-1;
C:= X div 100000;
SN1:= 0;
For i:= 0 to C-1 do begin
T:= i;
While T <> 0 do begin
SN1:= SN1+(T mod 10);
T:= T div 10;
end;
end;
SN1:= 100000*SN1+C*SA0;
For i:= X-(X mod 100000) to X do begin
T:= i;
While T <> 0 do begin
SN1:= SN1+(T mod 10);
T:= T div 10;
end;
end;
WriteLn((SN2-SN1):0:0);
end.