Cod sursa(job #1943291)
Utilizator | Data | 28 martie 2017 14:53:42 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#include<fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p;
bool check(int val)
{
int s=0,x,f=5;
x=val;
while(x/f!=0)
{
s=s+x/f;
f=f*5;
}
if(s>=p)
return true;
else
return false;
}
int cautbin()
{
int l=1,r=5000000000,sol,mid;
while(l<=r)
{
mid=(l+r)/2;
if(check(mid)==1)
{
sol=mid;
r=mid-1;
}
else
l=mid+1;
}
return sol;
}
int main()
{int i;
fin>>p;
fout<<cautbin();
}