Cod sursa(job #582846)
| Utilizator | Data | 16 aprilie 2011 09:52:53 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <cstdio>
using namespace std;
int p;
int main()
{
int i,n,ok;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
if(p==0)
{
printf("1");
return 0;
}
fclose(stdin);
for(i=p;;i++)
{
n=i;ok=0;
while(n/5!=0)
{
n/=5;
ok+=n;
}
if(ok==p)
{
printf("%d\n",i);
return 0;
}
if(ok>p)
break;
}
printf("-1\n");
fclose(stdout);
return 0;
}
