Pagini recente » Cod sursa (job #2045676) | Cod sursa (job #962315) | Cod sursa (job #609715) | Cod sursa (job #816002) | Cod sursa (job #3230868)
#include <bits/stdc++.h>
using namespace std;
int v[100001],n;
bool check(int val,int target)
{
long long p5=5,cnt=0;
while(p5<=val)
{
cnt+=val/p5;
p5*=5;
}
return (cnt>=target);
}
int cb(int val)
{
int st=1,dr=1e8*5,mid,rasp;
while(st<=dr)
{
mid=(st+dr)/2;
if(check(mid,val))
{
rasp=mid;
dr=mid-1;
}
else st=mid+1;
}
return rasp;
}
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
int p;
fin>>p;
fout<<cb(p);
return 0;
}