Cod sursa(job #518518)
Utilizator | Data | 1 ianuarie 2011 16:51:15 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include <cstdio>
using namespace std;
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
unsigned long long int x;
int p,q=1,t;
scanf ("%d",&p);
while (t<p)
{
x=1;
for (int i=q;i<q+5;i++)
x*=i;
while (x%10==0)
{
x/=10;
t++;
}
q+=5;
}
if (t==p)
printf ("%d \n",q-1);
else
printf ("-1 \n");
}