Pagini recente » Cod sursa (job #884445) | Cod sursa (job #176954) | Rating Croitoru Andra (andramaria23) | Cod sursa (job #1294118) | Cod sursa (job #2196984)
#include <iostream>
#include <cstdio>
using namespace std;
int numarzero(int n)
{
int nr=0;
while(n!=0)
{
nr=nr+n/5;
n=n/5;
}
return nr;
}
int main()
{
freopen("factorial.in","r",stdin);
freopen("factorial.out","w",stdout);
int P; scanf("%d", &P);
int m,u,p;
p=1;
u=5*P;
while (p<=u)
{
m = p+(u-p)/2;
if (numarzero(m)>=P)
u = m-1;
else
p = m+1;
}
cout<<p;
return 0;
}