Pagini recente » Cod sursa (job #1693575) | Cod sursa (job #1264441) | Cod sursa (job #1880424) | Cod sursa (job #743022) | Cod sursa (job #743551)
Cod sursa(job #743551)
#include <fstream>
using namespace std;
bool is5pow(long x)
{
long y = 1;
while(y < x)
{
y *= 5;
}
if(x == y)
return true;
return false;
}
int main()
{
long p, pow, zeros, i;
ifstream fin("fact.in");
ofstream fout("fact.out");
fin>>p;
fin.close();
if(p == 0)
fout<<1;
else
{
for(i = 0, zeros = 0, pow = 0; zeros <= p; i += 5)
{
if(!is5pow(i))
++zeros;
else
{
++pow;
zeros += pow;
}
}
if(zeros == p + 1)
fout<<i - 5;
else
fout<< -1;
}
fout.close();
return 0;
}