Mai intai trebuie sa te autentifici.
Cod sursa(job #199645)
Utilizator | Data | 19 iulie 2008 22:38:16 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
program gaju;
var x,y:longint;
f,g:text;
function p(x,y:longint):longint;
begin
if y>1 then begin
if y mod 2=0 then p:=(sqr(p(x,y div 2)))mod 1999999973
else p:=(sqr(p(x,(y-1)div 2))*x)mod 1999999973;
end else p:=x;
end;
begin
assign(f,'lgput.in');reset(f);
assign(g,'lgput.out');rewrite(g);
readln(f,x,y);
if y<>0 then writeln(g,p(x,y))
else writeln(g,1);
close(g);
end.