Pagini recente » Cod sursa (job #3191566) | Cod sursa (job #1770260) | Cod sursa (job #3181133) | Cod sursa (job #2341449) | Cod sursa (job #2666647)
#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;
while(n > 0)
{
nr += n / 5;
n /= 5;
}
return nr;
}
int main()
{
int p,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;
}