Cod sursa(job #2892982)
Utilizator | Data | 24 aprilie 2022 13:01:01 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int pow5(int m);
int main()
{
int n;
fin >> n;
if(n == 0)
fout << 1;
else
{
int m = 5 * n;
while(pow5(m) > n)
m -= 5;
if(pow5(m) == n) fout << m;
else fout << -1;
}
return 0;
}
int pow5(int m)
{
int c = 0;
while(m)
{
c += m / 5;
m /= 5;
}
return c;
}