Pagini recente » Cod sursa (job #456432) | Cod sursa (job #106799) | Cod sursa (job #176332) | Cod sursa (job #2249170) | Cod sursa (job #152719)
Cod sursa(job #152719)
type vec=array[1..2000] of integer;
var v:vec;
i,b,c,k:longint;
s,a:int64;
begin
assign(input,'lgput.in');reset(input);
assign(output,'lgput.out');rewrite(output);
read(a,b);
c:=1999999973;
k:=1;
while b>1 do
begin
if b mod 2=0 then
begin
v[k]:=0;
inc(k);
b:=b div 2;
end
else
begin
v[k]:=1;
inc(k);
b:=b-1;
end;
end;
s:=a;
for i:=(k-1) downto 1 do
if v[i]=0 then
s:=(s*s) mod c
else
s:=(s*a) mod c;
write(s mod c);
end.