POJ 1306 Combinations

// 求 C[n][m]
// 组合公式 C[i][j]=C[i-1][j-1]+C[i-1][j];
#include <iostream>
#include <string>
#include<sstream>
#include <cmath>
#include <map>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define  LL long long
LL C[123][123];
int main()
{
   int i,j;
   for(i=0;i<=100;i++) C[i][0]=1;
   for(i=1;i<=100;i++)
     for(j=1;j<=i;j++)
       C[i][j]=C[i-1][j-1]+C[i-1][j];
   int n,k;
   while(scanf("%d %d",&n,&k),n|k)
   {
      printf("%d things taken %d at a time is %lld exactly.
",n,k,C[n][k]);
   }
   return 0;
}
原文地址:https://www.cnblogs.com/372465774y/p/3603215.html