Cod sursa(job #3002349)
Utilizator | Data | 14 martie 2023 17:45:54 | |
---|---|---|---|
Problema | Factorial | Scor | 80 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p;
int main()
{
fin >> p;
if (p == 0)
fout << 1;
else
{
for (int i = 5; ; i += 5)
{
int x = i;
while (x % 5 == 0)
{
x /= 5;
p--;
}
if (p == 0)
{
fout << i;
break;
}
else if (p < 0)
{
fout << -1;
break;
}
}
}
}