Cod sursa(job #2062288)

Utilizator GhiciCineRazvan Dumitriu GhiciCine Data 10 noiembrie 2017 10:33:56
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <cstdio>
#define L 24

using namespace std;

int zero( int n ) {
  int x = 0;

  while( n ) {
    x += n / 5;
    n /= 5;
  }

  return x;
}

int main( ) {
  int p, r, pas;

  freopen( "fact.in", "r", stdin );
  freopen( "fact.out", "w", stdout );

  scanf( "%d", &p );
  r = 0;
  pas = 1 << L;
  while( pas != 0 ) {
    if( zero( r + pas ) < p )
      r += pas;
    pas /= 2;
  }
  printf( "%d", r + 1 );
  return 0;
}