Cod sursa(job #2593982)
Utilizator | Data | 5 aprilie 2020 01:40:14 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream fin("fact.in", ios::in);
fstream fout("fact.out", ios::out);
int p, k = 0, x = 1, N;
cout << "P: ";
fin >> p;
if (p < 1)
{
fout << "-1";
}
else
{
while (k < p)
{
N = 5 * x;
while (N % 5 == 0)
{
k++;
N /= 5;
}
x++;
}
fout << 5*x - 5;
}
}