Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
Statistical Charts
Submit Problem
Online Status
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Ikki's Story III - Rescue frkstyc!
Time Limit: 3000MSMemory Limit: 262144K
Total Submissions: 732Accepted: 127


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!


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 the numbers of different forests in separate lines.

Sample Input

1 1
3 2
0 0

Sample Output



[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator