static int numberOfPartitions ( String binaryNo ) {
  int i , j , n = binaryNo . length ( ) ;
  long val ;
  int dp [ ] = new int [ n ] ;
  dp [ n - 1 ] = ( ( ( binaryNo . charAt ( n - 1 ) - '0' ) == 0 ) ? - 1 : 1 ) ;
  for ( i = n - 2 ;
  i >= 0 ;
  i -- ) {
    val = 0 ;
    if ( ( binaryNo . charAt ( i ) - '0' ) == 0 ) {
      dp [ i ] = - 1 ;
      continue ;
    }
    dp [ i ] = Integer . MAX_VALUE ;
    for ( j = i ;
    j < n ;
    j ++ ) {
      val = ( val * 2 ) + ( long ) ( binaryNo . charAt ( j ) - '0' ) ;
      if ( isPowerOf ( val , 4 ) || isPowerOf ( val , 6 ) ) {
        if ( j == n - 1 ) {
          dp [ i ] = 1 ;
        }
        else {
          if ( dp [ j + 1 ] != - 1 ) dp [ i ] = Math . min ( dp [ i ] , dp [ j + 1 ] + 1 ) ;
        }
      }
    }
    if ( dp [ i ] == Integer . MAX_VALUE ) dp [ i ] = - 1 ;
  }
  return dp [ 0 ] ;
}

static int numberOfPartitions ( String binaryNo ) { int i , j , n = binaryNo . length ( ) ; long val ; int dp [ ] = new int [ n ] ; dp [ n - 1 ] = ( ( ( binaryNo . charAt ( n - 1 ) - '0' ) == 0 ) ? - 1 : 1 ) ; for ( i = n - 2 ; i >= 0 ; i -- ) { val = 0 ; if ( ( binaryNo . charAt ( i ) - '0' ) == 0 ) { dp [ i ] = - 1 ; continue ; } dp [ i ] = Integer . MAX_VALUE ; for ( j = i ; j < n ; j ++ ) { val = ( val * 2 ) + ( long ) ( binaryNo . charAt ( j ) - '0' ) ; if ( isPowerOf ( val , 4 ) || isPowerOf ( val , 6 ) ) { if ( j == n - 1 ) { dp [ i ] = 1 ; } else { if ( dp [ j + 1 ] != - 1 ) dp [ i ] = Math . min ( dp [ i ] , dp [ j + 1 ] + 1 ) ; } } } if ( dp [ i ] == Integer . MAX_VALUE ) dp [ i ] = - 1 ; } return dp [ 0 ] ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (parenthesized_expression (ternary_expression condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal))) right: (decimal_integer_literal))) consequence: (unary_expression operand: (decimal_integer_literal)) alternative: (decimal_integer_literal))))) (for_statement init: (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))) (continue_statement))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (field_access object: (identifier) field: (identifier)))) (for_statement init: (assignment_expression left: (identifier) right: (identifier)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))))))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (field_access object: (identifier) field: (identifier)))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal))))))) (return_statement (array_access array: (identifier) index: (decimal_integer_literal)))))