Mai intai trebuie sa te autentifici.
Cod sursa(job #604346)
| Utilizator | Data | 21 iulie 2011 20:37:07 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.76 kb |
program factorial;
var p,i:longint;
rez:real;
f,g:text;
cond:boolean;
aux:int64;
begin
assign (f,'fact.in'); reset (f);
assign (g,'fact.out'); rewrite (g);
read (f,p);
aux:=5;
cond:=false;
for i:=2 to 13 do begin if (aux=p) then begin cond:=true;
break;
end;
aux:=aux*5;
end;
if (p<>0) and (cond<>true) then begin rez:=int(5*(p-int(ln(5*p)/ln(5)-1)));
write (g,rez:10:0);
end
else if (p=0) then write (g,'1')
else if (cond) then write (g,'-1');
close (f);
close (g);
end.
