Minimum number of cuts required to pay salary from N length Gold Bar | CPP Implementation to find the minimum number of cuts to pay the worker . ; Function to find the minimum number of cuts to pay the worker . ; Nearest Integer to the Log value of the number N ; Driver code ; Cuts Required in the Length of 15
#include <bits/stdc++.h> NEW_LINE using namespace std ; int pay ( int n ) { int cuts = int ( log ( n ) / log ( 2 ) ) ; return cuts ; } int main ( ) { int n = 5 ; int cuts = pay ( n ) ; cout << cuts << endl ; n = 15 ; cuts = pay ( n ) ; cout << ( cuts ) ; return 0 ; }