Cod sursa(job #591439)
| Utilizator | Data | 24 mai 2011 10:39:02 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.34 kb |
#include <fstream.h>
ifstream in("factorial.in");
ofstream out("factorial.out");
long long n,e,i,aux;
int main()
{
in >> n;
if (n==0)
out << 1;
else if (n==1)
out << 5;
else
{
e = 0;
for (i=5;e<n;i+=5)
{
aux = i;
while (aux%5==0)
{ e++; aux/=5; }
}
if (e==n)
out << i-5;
else
out << -1;
}
}