Pagini recente » Cod sursa (job #2225716) | Cod sursa (job #2695029) | Istoria paginii runda/rar4/clasament | Cod sursa (job #460640) | Cod sursa (job #2988807)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
void binar(int p)
{
long long s=1,e=100000,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;
}