Pagini recente » Cod sursa (job #1493531) | Cod sursa (job #451746) | Profil MariaSfiraiala | Cod sursa (job #2564853) | Cod sursa (job #1711548)
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long p,bot=1,top=1000000000,mid,z;
int nrnada(int h)
{int nr=0;
while(h>=5)
{
nr+=(h/=5);
}
return nr;
}
int main()
{
fin>>p;
if(!p)fout<<1;
else{while(bot<=top)
{
mid=(bot+top)/2;
z=nrnada(mid);
if(z>=p)top=mid-1;
else bot=mid+1;
}
if(nrnada(bot)==p)fout<<bot;
else fout<<-1;
}
return 0;
}