Cod sursa(job #1803558)
| Utilizator | Data | 11 noiembrie 2016 16:30:17 | |
|---|---|---|---|
| Problema | Factorial | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <cstdio>
using namespace std;
int nr_cif(int n)
{
int r,s=0;
r=5;
while(r<=n)
{
s=s+n/r;
r=r*5;
}
return s;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int p,n=0,st,dr,med;
scanf("%d",&p);
if(p){
st=1;
dr=70000000;
while(dr!=0){
if(nr_cif(st+dr)<p)
st=st+dr;
dr=dr/2;
}
st++;
if(nr_cif(st)!=p)
printf("-1");
else
printf("%d",st);
}
else
printf("1");
return 0;
}
