1. 1000以内的较多组合数求解;利用C(n,m) = C(n-1,m) + C(n-1,m-1)求解;
const int N = 1005; ll f[N][N]; void init(int n) { f[0][0] = 1; for(int i = 1;i <= n;i++){ f[i][0] = 1; for(int j = 1;j <= i;j++) f[i][j] = f[i-1][j] + f[i-1][j-1]; } }
时间: 2024-10-09 01:19:25
1. 1000以内的较多组合数求解;利用C(n,m) = C(n-1,m) + C(n-1,m-1)求解;
const int N = 1005; ll f[N][N]; void init(int n) { f[0][0] = 1; for(int i = 1;i <= n;i++){ f[i][0] = 1; for(int j = 1;j <= i;j++) f[i][j] = f[i-1][j] + f[i-1][j-1]; } }