Pagini recente » Cod sursa (job #729831) | Rating Manea TEodor (rocky66) | Cod sursa (job #1140927) | Cod sursa (job #1436854) | Cod sursa (job #2541565)
#include <iostream>
#include <fstream>
#define N 101
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int Nr0(int x)
{
int i,ct=0;
i=5;
while(x/i!=0)
{
ct+=x/i;
i*=5;
}
return ct;
}
int main()
{
int st=1,dr=500000000;
int m,p;
fin>>p;
while(st<=dr)
{
m=st+(dr-st)/2;
if(Nr0(m)<p) st=m+1;
else if(Nr0(m)>p) dr=m-1;
else {fout<<m-m%5;return 0;}
}
fout<<-1;
return 0;
}