Cod sursa(job #199703)
| Utilizator | Data | 20 iulie 2008 11:16:56 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.62 kb |
program gaju;
const q=1999999973;
var x,y:int64;
f,g:text;
function p(x,y:int64):int64;
var aux:int64;
begin
if y<>1 then begin
if y mod 2=0 then begin
aux:=p(x,y div 2);
p:=(aux*aux) mod q;
end
else begin
aux:=p(x,y-1);
p:=(aux*x)mod q;
end;
end
else p:=x;
end;
begin
assign(f,'lgput.in');reset(f);
assign(g,'lgput.out');rewrite(g);
readln(f,x,y);
writeln(g,p(x,y));
close(f);close(g);
end.