Cod sursa(job #2196986)
Utilizator | Data | 20 aprilie 2018 20:33:15 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#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("fact.in","r",stdin);
freopen("fact.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;
}