Cod sursa(job #2196984)
| Utilizator | Data | 20 aprilie 2018 20:32:12 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 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("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;
}
