Pagini recente » Cod sursa (job #233029) | Cod sursa (job #2565268) | Cod sursa (job #84913) | Cod sursa (job #2121243) | Cod sursa (job #600906)
Cod sursa(job #600906)
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream in ("fact.in");
ofstream out ("fact.out");
int n, i, count ,temp, fives;
in >> n;
count = 0;
fives = 0;
for (i = 1;count < n; i++)
{
if (i % 5 != 0)
count++;
else
{
temp = i;
while (temp % 5 == 0)
{
if (temp % 5 == 0 && temp % 10 != 0)
{
fives ++;
count += fives + 1;
break;
}
else
{
temp /= 5;
count ++;
}
}
count ++;
}
if (count == n)
{
out << i * 5;
break;
}
}
if (n == 0)
out << 1;
else
if (count > n)
out << -1;
return 0;
}