Cod sursa(job #505291)
Utilizator | Data | 1 decembrie 2010 15:34:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
var
n,p:longint;
f,g:text;
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 199999973;
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));
end.