Pagini recente » Cod sursa (job #2276852) | Cod sursa (job #1698725) | Cod sursa (job #2246595) | Cod sursa (job #2276960) | Cod sursa (job #1423726)
#include<fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int p,n,sol;
int nr0(int x)
{
int cnt=0;
int p=5;
while(p<=x)
{
cnt+=x/p;
p*=5;
}
return cnt;
}
int main()
{
in>>p;
if(!p)out<<"1\n";
int st=1,dr=10*p;
bool found =0;
while(st<dr&&!found)
{
int m=st+(dr-st)/2;
int aux=nr0(m);
if(aux==p)
{
sol=m;
found =1;
}
else if(aux>p)
dr=m-1;
else st=m+1;
}
while(nr0(sol)==p)sol--;
out<<sol+1<<'\n';
out.close();
return 0;
}