Pagini recente » Cod sursa (job #785149) | Cod sursa (job #1100808) | Cod sursa (job #1460676) | Cod sursa (job #1770013) | Cod sursa (job #1833022)
// Week 2 - prob 3.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
int n, nr_de_zero, s=0, putere=5;
//cin >> nr_de_zero;
f>>nr_de_zero;
if (nr_de_zero == 0) g<<1; //cout << 1;
else
{
for (n = 5; ; n+=5)
{
putere = 5;
s = 0;
while (putere <= n)
{
s += n / putere;
putere *= 5;
}
if (s == nr_de_zero)
{
break;
}
else if (s > nr_de_zero)
{
break;
}
}
if (s == nr_de_zero)
{
//cout << n << '\n';
g<<n<<'\n';
}
else g<< "-1\n"; //cout << "-1\n";
}
return 0;
}