Pagini recente » Cod sursa (job #3002678) | Cod sursa (job #512555) | Cod sursa (job #2623476) | Cod sursa (job #2490308) | Cod sursa (job #600909)
Cod sursa(job #600909)
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream in ("fact.in");
ofstream out ("fact.out");
int n, i, count ,temp;
in >> n;
count = 0;
/*
for (i = 1;count < n; i++)
{
if (i % 5 != 0)
count++;
else
{
temp = i;
while (temp % 5 == 0)
{
count ++;
temp /= 5;
}
count ++;
}
if (count == n)
{
out << i * 5;
break;
}
}*/
i = n * 5;
int pivot = 25;
int fives = 5;
count = 1;
if (25 == i)
out << -1;
else
while (count * pivot <= i)
{
i -= fives;
count ++;
if (count == 5)
{
pivot *= 5;
count = 1;
fives +=5;
}
}
/*
if (n == 0)
out << 1;
else
if (count > n)
out << -1;*/
if (n == 0)
out << -1;
else
out << i;
return 0;
}