Under construction

Still being built. Things may change

Increasing Sequence Card Game

Time limit20sMemory limit1024 MB

Summary
For each N, compute the expected number of cards kept when a shuffled 1..N pile is scanned and a card is taken only if it exceeds the last taken card.
Level

Medium6 of 10

Topics
Probability, Math, Dynamic programming, Combinatorics
Solved
No attempts yet

Problem

You are playing a card game by yourself.

There are N cards. The i-th card has the integer i written on it.

First you shuffle the N cards randomly and make them into a pile. You take the card at the top of the pile into your hand. Then you repeat the following process until the pile becomes empty:

  1. Check the card on the top of the pile.
  2. If the number on the card is larger than the number on the last card you took, take the card.
  3. Otherwise, discard the card.

The score of the game is the number of cards in your hand at the end. For a given number of cards N, what is the expected score of the game?

Input

The first line of the input contains the number of test cases, T. The next T lines follow. Each line contains a single integer N, the number of cards in the pile.

Output

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the expected score at the end of the game.

y will be considered correct if it is within an absolute or relative error of 10-6 of the correct answer.

Limits

  • 1 ≤ T ≤ 100.

Examples1

  1. Example 1

    Input
    2
    1
    2
    
    Expected output
    Case #1: 1.0
    Case #2: 1.5