组合数2
#include<iostream> #include<cstdio> using namespace std; const int MAXN=102; __int64 C[MAXN+1][MAXN+1]; int n,m; void f() { int i,j; for(i=0;i<=MAXN;i++) { C[0][i]=0; C[i][0]=1; } for(int i=1;i<=MAXN;i++) { for(j=1;j<=MAXN;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1]); } } int main() { std::ios::sync_with_stdio(false); f(); while(~scanf("%d%d",&n,&m)&&(n||m)) { printf("%d things taken %d at a time is %I64d exactly.\n",n,m,C[n][m]); } return 0; }
可与我的《组合数》这篇文章互见,体验一种玄学。