Pagini recente » Cod sursa (job #555438) | Cod sursa (job #2156584) | Cod sursa (job #19746) | Cod sursa (job #2742655) | Cod sursa (job #2785341)
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
class Problema
{
int p;
public:
Problema(void)
{
p = 0;
}
Problema(int x)
{
p = x;
}
void Rezolvare()
{
int p2 = 0, p5 = 0;
int x = 0,y;
while (p2 < p || p5 < p)
{
if ((x + 1) % 2 == 0) {
y = x+1;
while (y % 2 == 0) {
y = y / 2;
p2++;
}
}
if ((x + 1) % 5 == 0)
{
y = x + 1;
while (y % 5 == 0) {
y = y / 5;
p5++;
}
}
x++;
}
if (x == 0)
fout << 1;
else
fout << x;
}
};
int main()
{
int p;
fin >> p;
Problema po(p);
po.Rezolvare();
}