递推求组合数
組合數計算公式:
遞推公式:
代碼模板:
#include <iostream> using namespace std; const int N = 1010; int c[N][N];int main() {int a,b;cin>>a>>b;//a在下,b在上for (int i = 0;i<N;i++)for (int j = 0;j<=i;j++){if (!j) c[i][j] = 1;else c[i][j] = c[i-1][j]+c[i-1][j-1];}cout<<c[a][b]<<endl;return 0; }總結
- 上一篇: 利用ps如何制作动态gif?
- 下一篇: 这件事情需要提前做好准备做事情要提前做好