Cod sursa(job #252363)
Utilizator | Data | 4 februarie 2009 12:14:37 | |
---|---|---|---|
Problema | Factorial | Scor | 60 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
# include <fstream>
using namespace std;
int main ()
{
int p, i, nrz=0, c, n;
ifstream fin ("fact.in");
ofstream fout ("fact.out");
fin>>p;
if (p==0)
fout<<"1";
else
{
for (i=5;nrz<p;i+=5)
{
c=i, n=i;
while (c%5==0)
{
nrz++;
c/=5;
}
}
if (nrz==p)
fout<<n;
else
fout<<"-1";
}
return 0;
}