Pagini recente » Cod sursa (job #1737820) | Monitorul de evaluare | Cod sursa (job #158411) | Cod sursa (job #1251317) | Cod sursa (job #2245815)
#include <fstream>
using namespace std;
int nrzero(const int& p)
{
int x = 5;
int y = 0;
while (p / x > 0)
{
y += p / x;
x *= 5;
}
return y;
}
int main()
{
ifstream in("fact.in");
ofstream out("fact.out");
int p;
in >> p;
int x = 5;
if(p == 0) out<<1;
while (true)
{
if (nrzero(x) < p) x++;
else break;
}
if (nrzero(x) == p) out << x;
else out << -1;
return 0;
}