Cod sursa(job #1074241)

Utilizator vlad.florescu94FMI Florescu Vlad - Adrian vlad.florescu94 Data 7 ianuarie 2014 13:28:04
Problema Factorial Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
const int nmax=10e+8;
int hap,k,n,i,p;
int zeros(int n)
{
    int nr=0;
    while(n)
    {
        nr+=n/5;
        n/=5;
    }
    return nr;
}
int caut_bin(int st,int dr,int x)
{
    int m,rasp=-1;
    while(st<=dr)
       {m=(st+dr)/2;
        if(zeros(m)==x)
          {
            rasp=m;
            dr=m-1;
          }
        else
            if(zeros(m)>x)
              dr=m-1;
            else
              st=m+1;
       }
    return rasp;
}
int main()
{
    f>>n;
    k=5*nmax;
    g<<caut_bin(1,k,n);
    return 0;
}