Cod sursa(job #1364487)

Utilizator adi_barbulescu99Barbulescu adi_barbulescu99 Data 27 februarie 2015 18:10:44
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <fstream>

using namespace std;

int main()
{int x,f,ls,g=0,p,n,ld,Nmax;;
ld=Nmax;
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;
}