Pagini recente » Cod sursa (job #2622951) | Cod sursa (job #3277597) | Cod sursa (job #3171281) | Cod sursa (job #1318173) | Cod sursa (job #1116307)
Program logn;
var n,p: longint;
function putere(baza,exp : longint) : longint;
var aux : longint; rest: int64;
begin
if exp=0 then putere:=1
else begin
aux:=1; rest:=1999999973;
while exp>0 do
begin
if exp mod 2=1 then aux:=(aux*baza) mod rest;
baza:=sqr(baza) mod rest;
exp:=exp div 2;
end;
putere:=aux;
end;
end;
begin
assign(input,'lgput.in'); reset(input);
assign(output,'lgput.out'); rewrite(output);
readln(n,p);
writeln(putere(n,p));
close(input); close(output);
end.