Description
Novel-Supertv Digital TV Technology Co., Ltd is one of the leading digital TV technology solution providers in China. Novel-Supertv offers customized solutions for cable, satellite, terrestrial, IPTV, and handset TV networks. We
often hold some competitions, games and other activities, like playing ping pang ball, basket ball, climbing mounting, live battle CS
and so on.Last year we organized a planting tree activity, a colleague think out a
very interesting question
. The question is:
There are N (N>=2) trees, you can plant into several lines. If a line have and only have M (2<=M<=N) trees, we called it “M trees line”. We wonder the maximum lines of “M trees line” that it can be planted with the N trees. Now, can you make a program and tell us the answer?
For example:
![](http://oj.cs203.net/upload/201505/C.jpg)
Input
The input contains several lines. Each line contains two integer N and M separating with several blank characters . (2<=N<=10, 2<=M<=N).
Output
For each input line, you should output a line contains the maximum lines of “M trees line” that it can be planted.
Sample Input
3 2
4 2
4 3
Sample Output
3 6 1
给定N棵树,每行只能种M棵(不能多也不能少),最多能种多少行,允许一棵树同时属于几行。智力题,数据范围不大,可直接打表。除了打表以外我还没有找出可以做的方法……
2
3
4
5
6
7
8
9
2
1
0
0
0
0
0
0
0
0
3
3
1
0
0
0
0
0
0
0
4
6
1
1
0
0
0
0
0
0
5
10
2
1
1
0
0
0
0
0
6
15
4
1
1
1
0
0
0
0
7
21
6
2
1
1
1
0
0
0
8
28
7
2
1
1
1
1
0
0
9
36
10
3
2
1
1
1
1
0
10
45
12
5
2
1
1
1
1
1
其中几个难打的地方画图如下:有些真的不会想到竟然会是这样画的……![]()
#include<cstring> #include<algorithm> #include<iostream> #include<cstdio> #include<cstdlib> #include<queue> using namespace std; int mat[9][9]={ 1, 3, 6,10,15,21,28,36,45, -1, 1, 1, 2, 4, 6, 7,10,12, -1,-1, 1, 1, 1, 2, 2, 3, 5, -1,-1,-1, 1, 1, 1, 1, 2, 2, -1,-1,-1,-1, 1, 1, 1, 1, 1, -1,-1,-1,-1,-1, 1, 1, 1, 1, -1,-1,-1,-1,-1,-1, 1, 1, 1, -1,-1,-1,-1,-1,-1,-1, 1, 1, -1,-1,-1,-1,-1,-1,-1,-1, 1 }; int main() { int M,N; while(scanf("%d%d",&N,&M)!=EOF) { printf("%d\n",mat[M-2][N-2]); } return 0; }