Pagini recente » Cod sursa (job #2929978) | Cod sursa (job #929522) | Cod sursa (job #604392) | Cod sursa (job #875916) | Cod sursa (job #2622761)
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cmath>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int nr_fact(long long x)
{
int nr = 0, p = 1, temp = 5;
while(temp <= x)
{
nr += x / temp;
p++;
temp = pow(5,p);
}
return nr;
}
int main()
{
long long N,P;
bool ok = true;
f>>P;
N = P * 5;
if(P == 0)
g<<1;
else
{
while(ok)
{
if(nr_fact(N-5) == P)
N -= 5;
else
ok = false;
}
g<<N;
}
f.close();
g.close();
return 0;
}