Cod sursa(job #1114283)
| Utilizator | Data | 21 februarie 2014 14:22:58 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.76 kb |
#include <fstream>
#include <climits>
using namespace std;
int zero(int n)
{
int x;
int k=0,y;
for(x=5;x<=n;x=x++)
{
y=x;
while(y%5==0)
{
k++;
y=y/5;
}
}
return k;
}
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
int N,P,ok,p,q,m;
f>>P;
N=1;
ok=0;
p=N;
q=INT_MAX;
while(p<=q)
{
N=(p+q)/2;
if(zero(N)==P)
{
ok=1;g<<N;break;
}
else
{
if(P>zero(N))
{
p=N+1;
}
else
{
q=N-1;
}
}
}
if(ok==0)
g<<-1;
return 0;
}
