The five disks P68007


Statement
 

pdf   zip

html

“To be able to choose between 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, one 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, 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 b and n, both between 0 and 1000. It holds b + n ≥ 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 in a line for how many of those ways 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++