Cod sursa(job #1273333)
| Utilizator | Data | 22 noiembrie 2014 15:07:10 | |
|---|---|---|---|
| Problema | Factorial | Scor | 85 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <cstdio>
using namespace std;
int f(int a)
{
int s=0,x=5;
while(x<=a)
{
s=s+a/x;
x = x*5;
}
return s;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int st=0,x,mij,dr=2000000000,p,n;
scanf("%d",&p);
while(st<=dr)
{
mij=(st+dr)/2;
if(f(mij)>p)
{
dr=mij-1;
}
if(f(mij)<p)
{
st=mij+1;
}
if(f(mij)==p)
n=mij,dr=mij-1;
}
printf("%d",n);
return 0;
}
