Pagini recente » Cod sursa (job #1129011) | Cod sursa (job #215806) | Cod sursa (job #1682347) | Diferente pentru problema/tequila intre reviziile 136 si 137 | Cod sursa (job #2892982)
#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;
}