QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 1024 MB Total points: 40

#5793. Collecting Cards

统计

Problem

You've become addicted to the latest craze in collectible card games, PokeCraft: The Gathering. You've mastered the rules! You've crafted balanced, offensive, and defensive decks! You argue the merits of various cards on Internet forums! You compete in tournaments! And now, as they just announced their huge new set of cards coming in the year 2010, you've decided you'd like to collect every last one of them! Fortunately, the one remaining sane part of your brain is wondering: how much will this cost?

There are C kinds of card in the coming set. The cards are going to be sold in "booster packs", each of which contains N cards of different kinds. There are many possible combinations for a booster pack where no card is repeated. When you pay for one pack, you will get any of the possible combinations with equal probability. You buy packs one by one, until you own all the C kinds. What is the expected (average) number of booster packs you will need to buy?

Input

The first line of input gives the number of cases, T. T test cases follow, each consisting of a line containing C and N.

Output

For each test case, output one line in the form

Case #x: E

where x is the case number,starting from 1, and E is the expected number of booster packs you will need to buy. Any answer with a relative or absolute error at most 10-5 will be accepted.

Limits

Time limit: 30 5 seconds per test set.

Memory limit: 1 GB.

1 ≤ T ≤ 100

Small dataset (10 Points)

1 ≤ NC ≤ 10

Large dataset (30 Points)

1 ≤ NC ≤ 40

Sample

2
2 1
3 2
Case #1: 3.0000000
Case #2: 2.5000000
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.