一本通 1304:数的划分
数的划分
Code:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
//Mystery_Sky
//
#define M 500
#define INF 0x3f3f3f3f
int f[M][M], n, k;
int main() {
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; i++) f[i][1] = 1;
for(int j = 2; j <= k; j++) {
for(int i = 2; i <= n; i++) {
if(i > j) f[i][j] = f[i-1][j-1] + f[i-j][j];
else if(i < j) f[i][j] = 0;
else f[i][j] = 1;
}
}
printf("%d\n", f[n][k]);
return 0;
}
唯愿,青春不辜负梦想,未来星辰闪耀