Cod sursa(job #3030347)
Utilizator | Data | 17 martie 2023 17:06:05 | |
---|---|---|---|
Problema | Factorial | Scor | 75 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
long long p, j = 0, x5=0, aux, k = 0;
fin >> p;
while(x5 < p)
{
k = 0;
j += 5;
aux = j;
while(aux % 5 == 0)
{
aux /= 5;
k++;
}
x5 += k;
}
if(p == 0) fout << 1;
else if(x5 == p) fout << j;
else fout << -1;
return 0;
}