Pagini recente » Cod sursa (job #1810993) | Cod sursa (job #685528) | Cod sursa (job #2675501) | Cod sursa (job #1440716) | Cod sursa (job #61819)
Cod sursa(job #61819)
var a,c,d:array[-100..10000000]of byte;
uc:integer;
n:int64;
i,j,max:longint;
m,l,aux,aux2,rest:int64;
s:ansistring;
fi,fo:text;
procedure imp(k:int64);
begin
j:=1;
for i:=1 to m do
begin
aux:=aux*10+a[i];
if aux>k then
begin
c[j]:=aux div k;
rest:=aux mod k;
inc(j);
aux:=rest;
end;
end;
end;
procedure sum(k:int64);
begin
aux2:=l;
j:=1000000;
for i:=m downto -100 do
begin
aux2:=aux2+a[i];
uc:=aux2 mod 10;
d[j]:=uc;
if d[j]<>0 then max:=j;
dec(j);
aux2:=aux2 div 10;
end;
end;
begin
assign(fi,'next.in'); reset(fi);
assign(fo,'next.out'); rewrite(fo);
a[0]:=0;
readln(fi,s);
for i:=1 to length(s) do
val(s[i],a[i]);
m:=length(s);
readln(fi,n);
aux:=0;
imp(n);
if aux=0 then
for i:=1 to m do
write(fo,a[i])
else
begin
l:=n-aux;
sum(l);
{if a[0]<>0 then
write(fo,c[0]);}
for i:=max to 1000000 do
write(fo,d[i]);
end;
close(fi);
close(fo);
end.