Pagini recente » Cod sursa (job #235875) | Cod sursa (job #2671928) | Cod sursa (job #2949571) | Cod sursa (job #775678) | Cod sursa (job #2666643)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int cate_zerouri_are_factorial_de(int n)
{
int nr = 0;
int putere5 = 1;
while(n)
{
putere5 *= 5;
nr += n / putere5;
n /= 5;
}
return nr;
}
int main()
{
int p,n,step,pos = -1;
fin >> p;
step = 1 << 30;
while(step > 0)
{
if(cate_zerouri_are_factorial_de(pos + step) < p)pos += step;
step /= 2;
}
if(cate_zerouri_are_factorial_de(pos + 1) == p)
{
fout << pos + 1;
}
else fout << -1;
return 0;
}