Cod sursa(job #1420373)

Utilizator ButnaruButnaru George Butnaru Data 18 aprilie 2015 13:04:39
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.37 kb
program lgput;
const modd=1999999973;
var n,x,sol:qword;
    f1,f2:text;
begin
assign (f1,'lgput.in');
assign (f2,'lgput.out');
reset (f1);
rewrite (f2);
readln (f1,x,n);
sol:=1;
while n>0 do begin
if n mod 2=1 then sol:=(sol mod modd)*(x mod modd) mod modd;
x:=(x mod modd)*(x mod modd) mod modd;
n:=n div 2;
end;
writeln (f2,sol);
close (f1);
close (f2);
end.