Pagini recente » Cod sursa (job #457985) | Cod sursa (job #1371915) | Cod sursa (job #618838) | Cod sursa (job #1775559) | Cod sursa (job #1526990)
#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[1000000000];
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(a == 0)
fout << 1;
else
if (suma == a)
fout << ((j-1) * 5);
else
fout << "-1";
fin.close();
fout.close();
return 0;
}