Pagini recente » Cod sursa (job #1255589) | Cod sursa (job #220127) | Cod sursa (job #1662843) | Cod sursa (job #2488470) | Cod sursa (job #2785414)
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int p;
fin >> p;
int p5 = 1;
int x = 5,y;
while (p5 < p)
{
p5 = p5 * 5 + 1;
x = x * 5;
}
if (p == 0)
fout << 1;
else
if (p5 == p)
fout << x;
else {
p5 = (p5-1)/5;
x = x / 5;
while (p5 < p)
{
x = x + 5;
y = x;
while (y % 5 == 0)
{
p5++;
y = y / 5;
}
}
if (p5 > p)
fout << -1;
else
fout << x;
}
}