Pagini recente » Istoria paginii runda/here_we_go/clasament | Cod sursa (job #1880648) | Statistici mihai baban (mihaibaban) | Rating Valerica Pohrib (Valerica1724) | Cod sursa (job #1520469)
#include <iostream>
# include<fstream>
#include<climits>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int nr0(int n)
{
int nr=0,p=5;
while(n>=p)
{
nr=nr+n/p;
p=p*5;
}
return nr;
}
int main()
{
int i,j,m,p,z,ok=0;
fin>>p;
i=1;
j=INT_MAX;
while(i<=j && ok==0)
{
m=(i+j)/2;
z=nr0(m);
if(z==p)ok=1;
else if(z>p)j=m-1;
else i=m+1;
}
if(p==0)fout<<1;
else if(ok==1)
{
while(m%5!=0)m--;
fout<<m;
}
else fout<<-1;
return 0;
}