Pagini recente » Cod sursa (job #382160) | Cod sursa (job #1719925) | Cod sursa (job #1655016) | Cod sursa (job #2236515) | Cod sursa (job #1114283)
#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;
}