随笔分类 -  组合数学

摘要:/*POJ 1671 Rhyme Schemesresult:ACtime: 0MS*/#include"iostream"using namespace std;double f[55][55];int main(){ int n; while(cin>>n,n) { int i,j; double ans=0; for(i=1;i<=n;i++){ f[i][1]=1; for(j=1;j<i;j++) f[i][j]=f[i-1][j-1]+j*f[i-1][j];//求第二类stirling数 f[i][i]=1; } for(j=1;j&l 阅读全文
posted @ 2011-07-25 20:44 Ac_smile 阅读(451) 评论(0) 推荐(0)
摘要:A factory produces products packed in square packets of the same height h and of the sizes 1x1, 2x2, 3x3, 4x4, 5x5, 6x6. These products are always delivered to customers in the square parcels of the same height h as the products have and of the size 6x6. Because of the expenses it is the interest of 阅读全文
posted @ 2011-05-13 15:29 Ac_smile 阅读(294) 评论(0) 推荐(0)
摘要:求在N中取M的个数,简单的组合数。#include"iostream" using namespace std; int main() { int n,k; while(cin>>n>>k,n!=0||k!=0) { if(n-k<k)//根据组合数的公式尽量约去大的部分 k=n-k; int count=k; __int64 ans=1; while(count--) { ans*=n--; while(ans%k==0&&k>1)//组合数结果一定是整数 { ans/=k; k--; } } printf(" 阅读全文
posted @ 2011-05-04 22:58 Ac_smile 阅读(287) 评论(0) 推荐(0)