private static double calc ( int c , int n , int need ) {
  if ( need == 0 ) return 0 ;
  if ( memo [ need ] != - 1 ) return memo [ need ] ;
  double ret = 1 ;
  int have = c - need ;
  for ( int good = 1 ;
  good <= Math . min ( n , need ) ;
  good ++ ) {
    int bad = n - good ;
    double p = choose ( need , good ) ;
    p *= choose ( have , bad ) ;
    p /= choose ( c , n ) ;
    ret += p * calc ( c , n , need - good ) ;
  }
  if ( have >= n ) {
    double p = choose ( have , n ) * 1.0 / choose ( c , n ) ;
    ret /= 1 - p ;
  }
  memo [ need ] = ret ;
  return ret ;
}

private static double calc ( int c , int n , int need ) { if ( need == 0 ) return 0 ; if ( memo [ need ] != - 1 ) return memo [ need ] ; double ret = 1 ; int have = c - need ; for ( int good = 1 ; good <= Math . min ( n , need ) ; good ++ ) { int bad = n - good ; double p = choose ( need , good ) ; p *= choose ( have , bad ) ; p /= choose ( c , n ) ; ret += p * calc ( c , n , need - good ) ; } if ( have >= n ) { double p = choose ( have , n ) * 1.0 / choose ( c , n ) ; ret /= 1 - p ; } memo [ need ] = ret ; return ret ; }
(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: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (return_statement (array_access array: (identifier) index: (identifier)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (binary_expression left: (identifier) right: (identifier))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))) right: (decimal_floating_point_literal)) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) (return_statement (identifier))))