组合数学(计算C)

考虑组合数Cmn

其实他们的方案数就是杨辉三角

此时有一个递推式

c[i][j]=c[i-1][j]+c[i-1][j];

#include<bits/stdc++.h>
using namespace std;
const int N=1000;
const int mod=1e9+7;
const int maxn=2010;
int c[maxn][maxn];
int a,b;
void init()
{
    for(int i=0;i<=N;i++)
    {
	    for(int j=0;j<=i;j++)
       {
		    if(j==0)
                c[i][j]=1;
            else c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
		}
	}
}
int main()
{
    init();
    int t;
	for(int i=0;i<=15;i++)
	{
		puts(" ");
		for(int j=0;j<=i;j++)
			cout<<c[i][j]<<" ";
	}
    return 0;
}

本文作者:邦的轩辕

本文链接:https://www.cnblogs.com/bangdexuanyuan/p/13681386.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   邦的轩辕  阅读(329)  评论(0编辑  收藏  举报
(评论功能已被禁用)
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
🔑
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.