Cod sursa(job #505294)
Utilizator | Data | 1 decembrie 2010 15:40:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
var
f,g:text;
n,p:longint;
function pow(a,n:int64):int64;
var p:int64;
begin
p:=1;
while n<>0 do
begin
if n mod 2=1 then p:=p*a mod 1999999973;
a:=a*a mod 1999999973;
n:=n div 2;
end;
pow:=p;
end;
begin
assign(f,'lgput.in');reset(f);
assign(g,'lgput.out');rewrite(g);
readln(f,n,p);
writeln(g,pow(n,p));
close(f);close(g);
end.