Pagini recente » Cod sursa (job #2906967) | Cod sursa (job #1121758) | Cod sursa (job #947752) | Cod sursa (job #308552) | Cod sursa (job #1549384)
#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 % 125 == 0 && i > 0)
{
i /= 125;
nr0 += 3;
}
while(i % 25 == 0 && i > 0)
{
i /= 25;
nr0 += 2;
}
while(i % 5 == 0 && i > 0)
{
i /= 5;
nr0++;
}
}
if(nr0 == P)
{
if(P == 0)
g << "1";
else
g << j-5;
}
else
g << "-1";
return 0;
}