Cod sursa(job #1364468)

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

using namespace std;

int main()
{int x,f,ls,ld=Nmax,g=0,p;
ifstream b("fact.in");
ofstream g("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)
{
    cout<<n;g=1;}
    else if(x<p) ls=n+1;
    else ld=n-1;
}
g<<p;


    return 0;
}