zoukankan      html  css  js  c++  java
  • 排列组合 C(n,k)= C(n1)+C(n1,k1) 对应于杨辉三角

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cmath>
     4 using namespace std;
     5 long long a[64][64];
     6 int main()
     7 {
     8     int m,n ,i,j;
     9     a[0][0]=a[1][0]=a[1][1]=1;
    10     for(i=2;i<64;i++)
    11     {
    12         a[i][0]=1;
    13         for(j=1;j<=i;j++)
    14         {
    15             a[i][j]=a[i-1][j]+a[i-1][j-1];
    16         }
    17     }
    18     while(~scanf("%d%d",&n,&m))
    19     {
    20         if(m||n) printf("%lld\n",a[m+n-1][m]);
    21         else break;
    22     }
    23     return 0;
    24 }
    25 
    26 /*由C(n,k) = C(n-1,k) + C(n-1,k-1);
    27 对应于杨辉三角:*/
  • 相关阅读:
    python的Collections 模块
    python模块
    python类
    python异常
    python文件处理
    python函数
    python字符串
    python数据结构
    python循环
    下载Google Play外国区APP技巧
  • 原文地址:https://www.cnblogs.com/yaling/p/3045494.html
Copyright © 2011-2022 走看看