Pagini recente » Cod sursa (job #147044) | Cod sursa (job #128979) | Cod sursa (job #479843) | Cod sursa (job #205576) | Cod sursa (job #153963)
Cod sursa(job #153963)
#include"fstream"
using namespace std;
long cati5(long x);
long p;
int main()
{
ifstream fin("fact.in");
fin>>p;
fin.close();
ofstream fout("fact.out");
long m=0,nr5=0;
if(p==0)
{
fout<<"1";
fout.close();
return 0;
}
while(nr5<p)
{
m+=5;
nr5+=cati5(m);
if(nr5==p)
{
fout<<m;
fout.close();
return 0;
}
}
fout<<"-1";
fout.close();
return 0;
}
long cati5(long x)
{
long contor=0;
while(x!=1)
{
x/=5;
contor++;
if(x%5!=0)
return contor;
}
return contor;
}