Pagini recente » Cod sursa (job #1551150) | Problema 2-satisfiabilității | Cod sursa (job #1544897) | Clasament go_nathan | Cod sursa (job #3238889)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int p, n, i, cnt, cop, n_cop, i_cop, cnt_cop, cop_cop;
fin >> p;
if(p==0)
fout << "1";
else
{
n=p*5;
i=25;
while(i<=n)
{
cnt=0;
cop=i;
while(cop%5==0)
{
cnt++;
cop/=5;
}
if(cnt!=0)
n=n-(cnt-1)*5;
i+=25;
}
n_cop=(p-1)*5;
i_cop=25;
while(i_cop<=n_cop)
{
cnt_cop=0;
cop_cop=i_cop;
while(cop_cop%5==0)
{
cnt_cop++;
cop_cop/=5;
}
if(cnt_cop!=0)
n_cop=n_cop-(cnt_cop-1)*5;
i_cop+=25;
}
if(n==n_cop)
fout << "-1";
else
fout << n;
}
return 0;
}