Pagini recente » Cod sursa (job #2207182) | Cod sursa (job #3169080) | Cod sursa (job #375101) | Cod sursa (job #1135892) | Cod sursa (job #923340)
Cod sursa(job #923340)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{ifstream fin("fact.in");
ofstream fout("fact.out");
int p,i,j,ok,k,nr,c;
fin>>p;
if(p==0)
fout<<"1";
else
{j=0;
i=0;
ok=1;
k=0;
while(1)
{i++;
k++;
j+=5;
nr=k;
if(k%5==0)
{c=0;
while(1)
{if(nr%5)
break;
nr/=5;
c++;
}
i=i+c;
}
if(i==p)
break;
else
if(i>p)
{
ok=0;
break;
}
}
if(ok==0)
fout<<"-1";
else
fout<<j;
}
return 0;
}