Pagini recente » Cod sursa (job #197654) | Cod sursa (job #3150905) | Cod sursa (job #3187867) | Cod sursa (job #2612878) | Cod sursa (job #2987690)
#include <fstream>
using namespace std;
ifstream in ("fact.in");
ofstream out ("fact.out");
int verif (int n)
{
short int fact=5;
int cnt=0;
while(fact<=n)
{
cnt+=n/fact;
fact*=5;
}
return cnt;
}
int main()
{
int p,st=0,dr=10000000,m,q;
in>>p;
while(st<=dr)
{
m=((st+dr)/2)*5;
q=verif(m);
if(m<p)
st=m+1;
else if(m>p)
dr=m-1;
else
{
out<<m-m%5;
return 0;
}
}
out<<-1;
return 0;
}