Programming contests

ECN selejtező programozó csapatverseny, 2013. április 28.

April 28, 2013, 10:15 AM – April 28, 2013, 3:15 PM

Poker End Games

Alice and Bob love playing poker with their friends. Unfortunately, they play poker way better than their friends. Thus, almost always they are the last two players to play. The two of them can play for a long time, and it bores their friends. So they changed the rule a little bit and decided that both of them will go all in every round. Now, Alice is wondering what is the expected length of the game and what is the probability that she will win the game.

Let's say, at the beginning of round i, Alice has ai Taka (currency of Bangladesh) and Bob has bi Taka, and ci is the minimum of ai and bi. Alice and Bob are equally likely to win the round. If Alice wins, she gets ci Taka from Bob, otherwise Bob gets ci Taka from her. The game ends when one of them has 0 (zero) Taka, and obviously, the person with 0 taka loses.

Given that the initial amount Alice has is a0, and the initial amount that Bob has is b0, you have to find the probability that Alice is going to win and the expected number of rounds the game will be played.

Input Specification

The input starts with a number T (0 < T ≤ 100). T test cases follow. The input for each test case is contained in a single line, and it consists of the two integers a and b (0 < ab ≤ 150).

Output Specification

For each test case, print the case number as shown in the sample output, followed by the expected number of rounds and the probability that Alice will win. Print both results rounded to 6 digits after the decimal point. For both values, errors less than 10-5 will be ignored.

Sample Input

  1. 2
  2. 1 1
  3. 2 1
download as text file

Output for Sample Input

  1. Case 1: 1.000000 0.500000
  2. Case 2: 2.000000 0.666667
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024