Cod sursa(job #1364497)
Utilizator | Data | 27 februarie 2015 18:15:43 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <fstream>
#define NMax 400000015
using namespace std;
int main()
{long long x,f,ls,g,p,n,ld;
ld=NMax;
g=0;
ls=5;
ifstream b("fact.in");
ofstream c("fact.out");
while(ls<=ld&&g==0)
{
n=(ls+ld)/2;
x=0;
f=5;
while(f<=n)
{
x=x+n/f;
f=f*5;
}
if(x==p)
{
c<<n;g=1;}
else if(x<p) ls=n+1;
else ld=n-1;
}
c<<p;
return 0;
}