Cod sursa(job #2636630)
Utilizator | Data | 18 iulie 2020 23:03:26 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<fstream>
#include<iostream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int numOf5(int a)
{
int b = 0;
while (a % 5 == 0)
{
b++;
a /= 5;
}
return b;
}
int main()
{
int n,p = 0, s = 5;
f >> n;
if (n == 0)
{
g << 1;
return 0;
}
while (p < n)
{
p += numOf5(s);
s += 5;
}
if (p == n)
g << s - 5;
else
g << -1;
return 0;
}