Pagini recente » Cod sursa (job #812880) | Cod sursa (job #802321) | Cod sursa (job #2815392) | Cod sursa (job #2718412) | Cod sursa (job #2988808)
#include <iostream>
#include <climits>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
void binar(int p)
{
long long s=1,e=INT_MAX,r=-1;
int putere = 5;
while(s<=e)
{
long long m;
long long c=0;
m=(s+e)/2;
putere=5;
while(putere <= m)
{
c += m / putere;
putere *= 5;
}
if(c==p)
{
r=m;
e=m-1;
}
else if(c<p)
{
s=m+1;
}
else if(c>p)
{
e=m-1;
}
}
fout<<r<<endl;
}
int main()
{
int p;
fin>>p;
binar(p);
return 0;
}