public static void main ( String [ ] args ) {
  Scanner input = new Scanner ( System . in ) ;
  int T = input . nextInt ( ) ;
  for ( int t = 0 ;
  t < T ;
  t ++ ) {
    System . out . printf ( "Case #%d: " , t + 1 ) ;
    int n = input . nextInt ( ) ;
    int p = input . nextInt ( ) , q = input . nextInt ( ) , r = input . nextInt ( ) , s = input . nextInt ( ) ;
    int [ ] data = new int [ n ] ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      data [ i ] = ( int ) ( ( ( long ) i * p + q ) % r + s ) ;
    }
    long lo = 1 , hi = ( long ) 1e13 ;
    while ( lo < hi - 1 ) {
      long mid = ( lo + hi ) / 2 ;
      if ( canDo ( data , mid ) ) hi = mid ;
      else lo = mid ;
    }
    if ( ! canDo ( data , lo ) ) lo ++ ;
    long sum = 0 ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) sum += data [ i ] ;
    double res = 1. * lo / sum ;
    System . out . printf ( "%.9f\n" , 1 - res ) ;
  }
}

public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int T = input . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { System . out . printf ( " Case ▁ # % d : ▁ " , t + 1 ) ; int n = input . nextInt ( ) ; int p = input . nextInt ( ) , q = input . nextInt ( ) , r = input . nextInt ( ) , s = input . nextInt ( ) ; int [ ] data = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { data [ i ] = ( int ) ( ( ( long ) i * p + q ) % r + s ) ; } long lo = 1 , hi = ( long ) 1e13 ; while ( lo < hi - 1 ) { long mid = ( lo + hi ) / 2 ; if ( canDo ( data , mid ) ) hi = mid ; else lo = mid ; } if ( ! canDo ( data , lo ) ) lo ++ ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += data [ i ] ; double res = 1. * lo / sum ; System . out . printf ( " % .9f \n " , 1 - res ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (binary_expression left: (identifier) right: (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) 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) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (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: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (cast_expression type: (integral_type) value: (identifier)) right: (identifier)) right: (identifier))) right: (identifier)) right: (identifier)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (decimal_floating_point_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier))) alternative: (expression_statement (assignment_expression left: (identifier) right: (identifier)))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))) consequence: (expression_statement (update_expression (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (decimal_floating_point_literal) right: (identifier)) right: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (binary_expression left: (decimal_integer_literal) right: (identifier)))))))))