Pagini recente » Cod sursa (job #858120) | Cod sursa (job #2193517) | Cod sursa (job #3144749) | Cod sursa (job #1790005) | Cod sursa (job #2846894)
#include <fstream>
using namespace std;
int main()
{
ifstream in("fact.in");
ofstream out("fact.out");
int n, x = 0, prev, sum = 0, step;
in >> n;
while(x <= n)
{
prev = x;
x = (x+1)*5;
}
step = prev;
x = prev;
while(x != 0)
{
while(step <= n)
{
prev = step;
sum += x/5;
step += x+1;
}
step = prev;
x = (x/5)-1;
}
if(prev == n)
out << -1;
else
out << (n-sum)*5;
// int sum = 0, aux = 0, k = 0;
// for(int i = 1; i <= n; i++)
// {
// k++;
// out << i << " : " << k << " " << i-k << endl;
// if(!(k%5))
// {
// aux = k;
// while(aux&&(!(aux%5)))
// {
// out << ++i << " : " << k << " " << i-k << endl;
// aux /= 5;
// }
// }
// }
}