集合划分问题

7 views
Skip to first unread message

效云 李

unread,
Apr 22, 2009, 3:29:39 AM4/22/09
to 编程爱好者天地
见算法实现题2-10

效云 李

unread,
Apr 24, 2009, 5:29:15 AM4/24/09
to 编程爱好者天地
这一题和11那题都是一模一样的,程序比较简单
// 递归分治-集合划分问题.cpp : Defines the entry point for the console
application.
//

#include "stdafx.h"
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int n=0;
ifstream finput;
finput.open("input.txt");
finput>>n;

vector<vector<int> > v(n+1,vector<int>(n+1));
v[1][1]=1;

int i=0,j=0;
for(i=2;i<=n;++i)
{
for(j=1;j<=n&&j<=i;++j)
{
v[i][j]=v[i-1][j-1]+j*v[i-1][j];
}
}

cout<<v[4][3];
system("pause");
return 0;
}

后来查了查资料,这里面其实是有BELL 数的问题,感觉,以后在写算法的同时,要加强数学方面的学习,向苏峰学习啊!

On 4月22日, 下午3时29分, 效云 李 <lixiaoyun...@gmail.com> wrote:
> 见算法实现题2-10

Reply all
Reply to author
Forward
0 new messages