Cod sursa(job #2278305)

Utilizator Dragomiralexandru621@yahoo.comDragomir ionut alexandru [email protected] Data 7 noiembrie 2018 16:59:25
Problema Factorial Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("fact.in") ;
ofstream g("fact.out") ;

int zero( int n )
{  int nr = 0;
   while( n >= 5 )
   {
       nr += n / 5 ;
       n /= 5 ;
}
    return nr ;

}
int main()
{int x ;
    f >> x ;
    int pas = 1<<30 , r = 0 ;
  while( pas )
  {
      if( zero( pas + r ) < x )
           r += pas ;
      pas = pas / 2 ;
  }

    if( zero( ++r ) == x )
        g << r ;
    else g<< "-1" ;
return 0 ;
}