The five disks P68007


Statement
 

pdf   zip

thehtml

“To be able to choose among the three suitors for his daughter, a king made an intelligence test to them. Initially, three white disks and two black disks were shown to the princes. Afterwards, and preventing them to see anything, a disk chosen at random was hang on the back of each prince. It was announced that the first prince who claimed with certainty the color of his own disk would win the hand of the princess. Before asking, the first prince was allowed to see the color of the disks of the other two, but he was unable to know for sure what color was his own disk, so he was eliminated. Knowing this, the second prince was allowed to see the color of the disk of the third one, but he could neither be sure of the color of his own disk, so he was eliminated too. Knowing all the foregoing, the third prince could deduce with certainty the color of his own disk. Which was it?”

This was another of the seven problems that Beremiz had to solve in the palace of the Caliph of Baghdad. The color of the disc was white.

Input

Input consists in several cases, each with two natural numbers w and b, both between 0 and ‍1000. We have w + b ≥ 3.

Output

Every case corresponds to the story of the three princes, but with a total of t = w + b disks, w of which are white and b of which are black. Suppose that each disk has a unique mark, so that there are t(t−1)(t−2) ways to distribute three of them.

Print a line with the number of those ways for which the first prince will win, the second prince will win, and the third prince will win. (In some cases there may be no winnner.)

Public test cases
  • Input

    3 2
    1 9
    

    Output

    6 18 36
    144 576 0
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++ Python