Pagini recente » Cod sursa (job #2327820) | Cod sursa (job #2326483) | Cod sursa (job #1047348) | Cod sursa (job #3139353) | Cod sursa (job #1753760)
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
unsigned long long a,b,c,k,k2,s=0;
unsigned long long int nrzerouri(unsigned long long int x)
{
unsigned long long int k1=0;
while(x%10==0)
{
k1++;
x=x/10;
}
return k1;
}
int main()
{
fin>>k;
if(k==0)
fout<<1;
else if(k==1)
fout<<5;
else
{
a=2;
b=4;
c=5;
k2=1;
while(s<k)
{
s=s+nrzerouri(a*b*c);
if(k2==1&&s!=k)
{
a=a+4;
b=b+4;
c=c+5;
k2=2;
}
else if(k2==2&&s!=k)
{
a=a+6;
b=b+6;
c=c+5;
k2=1;
}
}
}
if(s==k)
fout<<c;
else
fout<<-1;
fin.close();
fout.close();
return 0;
}