Pagini recente » Cod sursa (job #663050) | Cod sursa (job #2944841) | Cod sursa (job #822235) | Cod sursa (job #1639048) | Cod sursa (job #2151755)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int p,n,st,dr;
int main()
{
in>>p;
st=1;
dr=(1<<30);
while(st<=dr)
{
int mij=(st+dr)/2;
int pow=5,x=0;
while(pow<=mij)
{
x=x+mij/pow;
pow=pow*5;
}
if(x>=p)
dr=mij-1;
else st=mij+1;
}
int pow=5,x=0;
while(pow<=st)
{
x=x+st/pow;
pow=pow*5;
}
if(x!=p) out<<-1;
else out<<st;
return 0;
}