Pagini recente » Cod sursa (job #1985159) | Cod sursa (job #2451003) | Cod sursa (job #2313354) | Cod sursa (job #2977908) | Cod sursa (job #2553799)
#include<iostream>
#include<fstream>
#include<math.h>
#define fin "fact.in"
#define fout "fact.out"
int get_power(int n)
{
int i = 0;
bool ok = true;
while (ok != false)
{
int p = pow(5,i);
if (n > p)
{
ok = true;
i++;
}
else
{
ok = false;
}
}
return i - 1;
}
int main()
{
std::fstream in, out;
int n;
in.open(fin, std::ios::in);
in >> n;
in.close();
int res = 0;
out.open(fout, std::ios::out);
int i = get_power(n*5);
//std::cout << i;
if (n > 0)
{
res = (n - i) * 5;
}
if (n == 0)
{
res = 1;
}
if (n == 5)
{
res = -1;
}
out << res;
out.close();
return 0;
}