Pagini recente » Cod sursa (job #2953754) | Cod sursa (job #2709105) | Cod sursa (job #1745236) | Cod sursa (job #1815763) | Cod sursa (job #1549394)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
long P;
long i = 1;
long j = 5;
long nr0 = 0;
ifstream f("fact.in");
ofstream g("fact.out");
f >> P;
while(nr0 < P)
{
i = j;
j += 5;
nr0++;
while(i % 25 == 0 && i > 0)
{
i /= 5;
nr0++;
while(i % 25 == 0 && i > 0)
{
i /= 25;
nr0 += 2;
}
}
}
if(nr0 == P)
{
if(P == 0)
g << "1";
else
g << j-5;
}
else
g << "-1";
return 0;
}