#P3206. Ikki's Story III - Rescue frkstyc!
Ikki's Story III - Rescue frkstyc!
Description
After defeating the evil nation of TN and road reconstruction, the nation of Phoenix is now in perfect harmony. But as every old story goes, evil things will keep happening now and then. This day, a letter arrived at Ikki’s, saying that his friend, frkstyc, was kidnapped in the Wonderland of TopCoders.
It is not known who kidnapped frkstyc but it is known that he is a favorite of algorithmic contests and the reason for his kidnapping frkstyc was that he can’t solve a enumeration problem =.=, so he kidnapped frkstyc to help him. (What? Why not kidnap ACRush? Well… Still remember the story told by Guo Wei in Xi’an? — “Then why me but not somebody else!!”, yells frkstyc.)
Well, now frkstyc’s life is at stake! He is encountered with such a problem:
You know what a tree in graph theory is, right? Well, I’m interested in numbering the trees in such a way that the number of a vertex is always smaller than those of its descendants. And I’m interested in making the trees into forests such that there are n nodes and k leaves, satisfying the above property in each tree. Now tell me how many ways can I number such forests!
Being a contestant at POJ, you’re sure that if there’s no frkstyc, there will be no POJ Monthly for a time… So try your best to save his life!
Input
The input contains one or more lines ended with an integer pair “0 0
”. Each of the above lines contains two integers n, k (n, k ≤ 500), respectively.
Output
Output the numbers of different forests in separate lines.
1 1
3 2
0 0
1
4
Source
POJ Monthly--2007.03.04, Ikki