Cod sursa(job #2614201)
| Utilizator | Data | 11 mai 2020 14:03:50 | |
|---|---|---|---|
| Problema | Factorial | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
std::ifstream f("fact.in");
std::ofstream g("fact.out");
int main()
{
int p;
f >> p;
if (p == 0)
std::cout << 1;
int n = 5;
int nb_of5 = 0;
bool adev = true;
while (adev)
{
int temp = n;
do
{
temp /= 5;
nb_of5++;
} while (temp % 5 == 0);
//std::cout << n << " " << nb_of5 << ' ';
if (nb_of5 == p)
{
g << n;
return 0;
}
if (nb_of5 > p)
{
g << "-1";
return 0;
}
n+=5;
}
std::cout << n;
}