Pagini recente » Cod sursa (job #2801778) | Cod sursa (job #1087128) | Cod sursa (job #720568) | Cod sursa (job #2895093) | Cod sursa (job #39129)
Cod sursa(job #39129)
var a:array[1..1000010]of int64;
d,r:int64;
i,j,z,x:longint;
c:string;
procedure add;
var i:longint;
t:int64;
begin
t:=r;
i:=0;
while t>0 do
begin
i:=i+1;
if i>z then z:=z+1;
a[i]:=a[i]+t;
t:=a[i] div 10;
a[i]:=a[i] mod 10;
end;
end;
procedure rest;
var i:longint;
begin
r:=0;
for i:=z downto 1 do
begin
r:=(r*10+a[i]) mod d;
end;
end;
begin
assign(input,'next.in');
reset(input);
assign(output,'next.out');
rewrite(output);
readln(c);
readln(d);
z:=length(c);
for i:=1 to length(c) do
begin
a[z+1-i]:=ord(c[i])-ord('0');
end;
rest;
r:=(d-r) mod d;
add;
for i:=z downto 1 do
begin
write(a[i]);
end;
close(output);
end.