Pagini recente » Cod sursa (job #49117) | Cod sursa (job #2607145) | Cod sursa (job #2380806) | Cod sursa (job #3125548) | Cod sursa (job #1011252)
#include<iostream>
#include<fstream>
//#include<conio.h>
using namespace std;
int nrOfZeros(int y)
{
int x=y;
int nrZ=x;
while(x>=5)
{
x/=5;
nrZ+=x;
}
return nrZ;
}
//long maxim = 80000003;
long findTheOne(long current,long p)
{
long x=nrOfZeros(current);
if(nrOfZeros(current) > p)
return -1;
if(nrOfZeros(current) == p)
return current;
return findTheOne(current+1,p);
}
int main()
{
long p,n=1;
ifstream f("fact.in");
f>>p;
f.close();
n = (p==0)?1:findTheOne(p*0.8,p);
/*
float minim=10,maxim=0;
for(long i=0;i<=10000;i+=100)
{
cout<<"P= "<<i<<" N= "<<findTheOne((i*3)/4,i)<<endl;
cout<<(float)findTheOne(1,i)/i<<endl;
if(findTheOne(1,i)!=-1 && minim > (float)findTheOne(1,i)/i)
minim = (float)findTheOne(1,i)/i;
if(maxim < (float)findTheOne(1,i)/i)
maxim = (float)findTheOne(1,i)/i;
}
cout<<endl<<minim<<" "<<maxim<<endl;
*/
//getch();
ofstream g("fact.out");
g<<n<<"\n";
g.close();
return 0;
}