Pagini recente » Cod sursa (job #1927301) | Cod sursa (job #658038) | Cod sursa (job #408102) | Cod sursa (job #48688) | Cod sursa (job #1358314)
#include <cstdio>
#include <iostream>
#define n_max 100000000
#define inf 0x3f3f3f3f
using namespace std;
int nr ;
void caut_bin() ;
int main()
{
freopen( "fact.in" , "r" , stdin ) ;
freopen( "fact.out" , "w" , stdout ) ;
scanf( "%d" , &nr ) ;
caut_bin() ;
return 0;
}
int verif( int m )
{
int sum = 0 , i = 5 ;
while ( m / i )
{
sum += m / i ;
i *= 5 ;
}
if ( sum == nr )
return 0 ;
if ( sum > nr )
return 1 ;
return -1 ;
}
void caut_bin()
{
int st = 1 , dr = n_max , n = -1 ;
while ( st <= dr && n == -1 )
{
int m = st + ( dr - st ) / 2 ;
int k = verif(m) ;
if ( k == 1 )
dr = m - 1 ;
else if ( k == -1 )
st = m + 1 ;
else
{
n = m ;
}
}
while ( n % 5 )
n -- ;
printf( "%d\n" , n ) ;
}