Pagini recente » Cod sursa (job #1057491) | Cod sursa (job #179465) | Cod sursa (job #1078638) | Cod sursa (job #1627746) | Cod sursa (job #1526981)
#include <iostream>
#include <fstream>
using namespace std;
int lol(int x, int y)
{
if(x % 5 != 0)
return y;
else
{
y++;
return lol(x / 5, y);
}
}
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
int a, k;
fin >> a;
int b[100000];
for (int i = 1; i <= a; i++)
{
k = 1;
b[i] = lol(i, k);
}
for (int i = 1; i <= a; i++) cout << b[i] << " ";
int suma = 0;
int j = 1;
while (suma < a)
{
suma += b[j];
j++;
}
if (suma == a)
fout << (j * 5);
else
fout << "-1";
return 0;
}