Cod sursa(job #546586)
| Utilizator | Data | 5 martie 2011 09:57:42 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<iostream.h>
#include<fstream.h>
int main()
{
ifstream f;
f.open("fact.in");
ofstream g;
g.open("fact.out");
int l=0, p;
f>>p;
int aux,n,i;
int ok=1;
aux=5*p;
i=aux;
while (ok)
{ n=0;
aux=i;
while(aux!=0)
{
aux/=5;
n=n+aux;
}
if (n==p) ok=0;
else i-=5;
}
if (p==0) g<<"1";
else if (n==p) g<<i;
else g<<"-1";
f.close();
g.close();
return 0;
}