spoj#DTPOLY. Divide Polygon
Divide Polygon
Determine the number of ways to cut a convex polygon with N sides if the only cuts allowed are from vertex to vertex, each cut divides exactly one polygon into exactly two polygons, and you must end up with exactly K polygons. Consider each vertex distinct. For example, there are three ways to cut a square - the two diagonals and not cutting at all - but only two ways to cut it to form 2 polygons, and only one way to cut it to form 1 polygon. The order of cuts does not matter. Since the number of ways is very large, you should return the number taken modulo 1000000000 (one billion). If there is no way to cut the polygon into K pieces, return -1.
Input
- Input contains only 2 integers in one line: N (1 ≤ N ≤ 100) and K (1 ≤ K ≤ 100).
Output
- Output contains only one integer, the number of different ways to cut the polygon into K pieces.
Example
Input:
4 2
Output:
2