8787: The division of Numbers
- View
- Submit
- Statistics
- Questions
Total time limit:
1000ms
Memory Limit:
65536kB
Describe
The integer n is divided into k parts, and each copy cannot be empty, and any two parts cannot be the same (regardless of order).
For example: N=7,k=3, the following three kinds of sub-methods are considered to be the same.
1,1,5; 1,5,1; 5,1,1;
Ask how many different sub-methods there are. Output: An integer, which is a different method of division.
Input
Two integers n,k (6 < n <= 200,2 <= k <= 6), separated by a single space in the middle.
Output
An integer, that is, a different method of division.
Sample input
3 ·
Sample output
4
Tips
The four kinds of methods are: 1,1,5;1,2,4;1,3,3;2,2,3.
Similar to putting apples: http://www.cnblogs.com/shenben/p/5564870.html
#include <cstdio>#include<cmath>#include<iostream>using namespacestd;Const intmaxn=1101;intF[MAXN][MAXN];intn,k;intMain () {scanf ("%d%d",&n,&k); for(intI=1; i<=n;i++) f[i][1]=1, f[i][i]=1; for(intI=2; i<=n;i++) for(intj=1; j<i;j++) F[i][j]=f[i-j][j]+f[i-1][j-1]; printf ("%d", F[n][k]); return 0;}
8787: The Division of Numbers (and another apple)