Cod sursa(job #175814)
Utilizator | Data | 10 aprilie 2008 14:04:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 90 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
const m=1999999973;
var f:text;
n,p,s:real;
i:longint;
begin
assign(f,'lgput.in'); reset(f);
readln(f,n,p);
i:=0; s:=1;
while 1 shl i<p do
begin
if trunc(p) and (1 shl i)<>0 then
s:=trunc((s*n))mod m;
n:=trunc((n*n)) mod m;
inc(i);
end;
close(f); assign(f,'lgput.out'); rewrite(f);
writeln(f,trunc(s) mod m);
close(f);
end.