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