Cod sursa(job #929238)
Utilizator | Data | 26 martie 2013 22:09:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
Program p1;
const md=199999997;
var fi,fo:text; n,a,p:int64;
begin
assign(fi,'lgput.in'); reset(fi);
assign(fo,'lgput.out'); rewrite(fo);
read(fi,a,n); p:=1;
while n<>0 do begin
if n mod 2=1 then p:=(p*a) mod md;
a:=(a*a) mod md;
n:=n div 2;
end;
write(fo,p);
close(fi); close(fo);
end.