static double calc ( int i , int j , int k ) {
  if ( memo [ i ] [ j ] [ k ] >= 0 ) return memo [ i ] [ j ] [ k ] ;
  double ans = 0 ;
  if ( j == N ) return i == 1 ? 1.0 : 0.0 ;
  double p = 1.0 / ( j + 1 ) ;
  if ( k > 0 ) {
    ans = p * Math . max ( calc ( 0 , j + 1 , k ) , calc ( 1 , j + 1 , k - 1 ) ) + ( 1 - p ) * calc ( i , j + 1 , k ) ;
  }
  else {
    ans = p * calc ( 0 , j + 1 , k ) + ( 1 - p ) * calc ( i , j + 1 , k ) ;
  }
  return memo [ i ] [ j ] [ k ] = ans ;
}

static double calc ( int i , int j , int k ) { if ( memo [ i ] [ j ] [ k ] >= 0 ) return memo [ i ] [ j ] [ k ] ; double ans = 0 ; if ( j == N ) return i == 1 ? 1.0 : 0.0 ; double p = 1.0 / ( j + 1 ) ; if ( k > 0 ) { ans = p * Math . max ( calc ( 0 , j + 1 , k ) , calc ( 1 , j + 1 , k - 1 ) ) + ( 1 - p ) * calc ( i , j + 1 , k ) ; } else { ans = p * calc ( 0 , j + 1 , k ) + ( 1 - p ) * calc ( i , j + 1 , k ) ; } return memo [ i ] [ j ] [ k ] = ans ; }
(method_declaration (modifiers) type: (floating_point_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) index: (identifier)) right: (decimal_integer_literal))) consequence: (return_statement (array_access array: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) index: (identifier)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (ternary_expression condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) consequence: (decimal_floating_point_literal) alternative: (decimal_floating_point_literal)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (decimal_floating_point_literal) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))) (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal))))))) right: (binary_expression left: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier)))))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier)))) right: (binary_expression left: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))))))) (return_statement (assignment_expression left: (array_access array: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) index: (identifier)) right: (identifier)))))