Cod sursa(job #1774732)
Utilizator | Data | 9 octombrie 2016 13:20:55 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include<fstream>
#include<math.h>
using namespace std;
int caut_fact(int z)
{
int st=1,dr=5*(1e8);
while(st<=dr)
{
int mid=(st+dr)/2;
long long s=0,y=5;
while(y<=mid)
{
s=s+mid/y;
y=y*5;
}
if(z<=s)
{
dr=mid-1;
}
else
{
st=mid+1;
}
}
return st;
}
int main()
{
ifstream fin ("fact.in");
ofstream fout ("fact.out");
int x;
fin>>x;
fout<<caut_fact(x);
}