Cod sursa(job #32967)
Utilizator | Data | 18 martie 2007 19:21:37 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include<fstream.h>
int main(){
ifstream fin("fact.in");
ofstream fout("fact.out");
int P,nr,x=0,N=0;
fin>>P;
short ok=1;
if (P==0)
fout<<1;
else
while (N!=P){
x+=5;
nr=x;
while (nr%5==0){
nr/=5;
N++;}
if (N>P) {
fout<<-1;
ok=0;
break; }}
if (ok==1)
fout<<x;
fin.close();
fout.close();
return 0;
}