Cod sursa(job #2489010)

Utilizator TomKodeColev Thomas-Daniel TomKode Data 7 noiembrie 2019 21:17:00
Problema Factorial Scor 5
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int nrz(int x,int put)
{
    if(x/put)
        return x/put + nrz(x,put*5);
}
int main()
{
    int p,x=5,aux,st=1;
    fin>>p;
    int dr=p*10;
    if(!p)
        fout<<1;
    else{
while(st<=dr)
{
  int mij=(st+dr)/2;
  if(nrz(mij,5)==p)
  {
      while(nrz(mij,5)==p)
      {
          --mij;
      }
fout<<mij+1;
break;
  }
  else
  if(nrz(mij,5)>p)
    dr=mij-1;
    else
        st=mij+1;

}

    }
    }