Pagini recente » Cod sursa (job #3254431) | Cod sursa (job #685778) | Cod sursa (job #2568473) | Cod sursa (job #2790835) | Cod sursa (job #2052375)
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int nrzero(int x)
{
int s=0;
long long p=5;
while(p<=x)
{
s=s+x/p;
p=p*5;
}
return s;
}
int main()
{ int p,x=5,y=2000000000,mij,a,b,gasit=0;
in>>p;
if(p==0)
{
out<<1;
return 0;
}
while(x<=y&&gasit==0)
{
mij=(x+y)/2;
b=nrzero(mij);
if(b==p)
gasit=1;
if(b<p)
x=mij+1;
else y=mij-1;
}
if(gasit==1) out<<mij-mij%5;
if(gasit==0) out<<-1;
return 0;
}