Pagini recente » Cod sursa (job #1518107) | Cod sursa (job #2845513) | Cod sursa (job #2192296) | Cod sursa (job #2769792) | Cod sursa (job #361281)
Cod sursa(job #361281)
Program ex;
var n,m,y,p : int64;
f,g : text;
Function exp(x,n : int64) : int64;
begin
if n=0 then exp:=1 else
if n mod 2=0 then
begin
y:=exp(x,n div 2) mod m;
exp:=y*y mod m;
end
else
exp:=((x mod m)*exp(x,n-1) mod m) mod m;
end;
begin
assign(f,'lgput.in'); assign(g,'lgput.out');
reset(f); rewrite(g);
readln(f,n,p);
m:=1999999973;
writeln(exp(g,n,p));
close(f);
close(g);
end.