Cod sursa(job #1420398)
Utilizator | Ionut Anghelina ionanghelina | Data | 18 aprilie 2015 13:38:57 |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<cstdio>
using namespace std;
int p;
long long zerouri(int p)
{
long long z=0;
int x=5;
while (x<=p)
{
z=z+p/x;
x*=5;
}
return z;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d ",&p);
// printf("%lld ",zerouri(5));
int x=1;
while (zerouri(x)<p) x++;
if (zerouri(x)==p) printf("%d\n",x);
else printf("-1\n");
return 0;
}