Cod sursa(job #1405535)
Utilizator | Butnaru George Butnaru | Data | 29 martie 2015 12:51:38 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
program lgput;
const modd=1999999973;
var p,sol,x:qword;
f1,f2:text;
begin
assign(f1,'lgput.in');
assign(f2,'lgput.out');
reset (f1);
rewrite (f2);
readln (f1,x,p);
sol:=1;
while p>0 do begin
if p mod 2=1 then sol:=(sol mod modd)*(x mod modd) mod modd;
x:=(x mod modd)*(x mod modd) mod modd;
p:=p div 2;
end;
writeln (f2,sol mod modd);
close (f1);
close (f2);
end.