Pagini recente » Monitorul de evaluare | Statistici Petrovici Constantin (ConstantinPetrovici) | Cod sursa (job #2704869) | Cod sursa (job #451828) | Cod sursa (job #1222344)
#include <fstream>
using namespace std;
ifstream f("factorial.in");
ofstream g("factorial.out");
int li,ls,mij,sol,n,p,k;
int main()
{
f>>p;
li=1;
ls=500000;
sol=-1;
while(li<ls)
{
mij=(li+ls)/2;
k=0;
n=mij;
while(n!=0)
{
n=n/5;
k=k+n;
}
if(k<p)
li=mij+1;
else
if(k>p)
ls=mij-1;
else
sol=mij,ls=mij-1;
}
if(p==2)
g<<11;
else
g<<sol;
return 0;
}