2011年5月7日

poj 2192

摘要: 简答dp代码:#include<iostream>#include<fstream>using namespace std;char a[201],b[201],c[401];bool dp[201][401];void read(){// ifstream cin("in.txt"); int i,j,k; int cas; cin>>cas; for(k=1;k<=cas;k++) { cin>>a>>b>>c; int n1=strlen(a); int n2=strlen(b); mems 阅读全文

posted @ 2011-05-07 18:20 宇宙吾心 阅读(306) 评论(0) 推荐(0)

poj 2475

摘要: 上下文无关文法。经典。代码:#include<iostream>#include<fstream>using namespace std;char c[300];int map[201][201][4];int Set(int ,int);int ElemList (int,int);int List(int,int);int Elem(int,int);int Atom(int,int);int Atom(int s,int t){ if(s==t) return 1; return 0;}int Elem(int s,int t){ if(map[s][t][3]& 阅读全文

posted @ 2011-05-07 17:22 宇宙吾心 阅读(362) 评论(0) 推荐(0)

poj 2948

摘要: dp水题代码:#include<iostream>#include<fstream>using namespace std;int dp[501][501];int a[501][501];int b[501][501];int n,m;void read(){// ifstream cin("in.txt"); int i,j,k; while(cin>>n>>m){ if(n==0) return; for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d" 阅读全文

posted @ 2011-05-07 15:01 宇宙吾心 阅读(304) 评论(0) 推荐(0)

poj 3042

摘要: 经典dp。代码:#include<iostream>#include<fstream>using namespace std;int a[1010];int dp[1010][1010][2];int v[1010][1010][2];int cmp(const void *a,const void *b){ return *(int*)a-*(int*)b;}int n,m;int solve(int s,int t,int f){ int i,j,k; if(v[s][t][f]) return dp[s][t][f]; v[s][t][f]=1; if(f==0) 阅读全文

posted @ 2011-05-07 14:26 宇宙吾心 阅读(337) 评论(0) 推荐(0)

poj 3088

摘要: 第一类斯特灵数S(n,m)就是把n元集合分成m部的个数,有递推关系S(n,m)=S(n-1,m-1)+mS(n-1,m).所求还要全排列一下.再乘以m!就可以了累加1~B个数全部用上,就是结果.F(B)=sum(C(B,i)*(Sum(Stir( i,j )* j ! ) ) )就是结果.代码:#include<iostream>#include<fstream>#include<cmath>using namespace std;long long dp[13][13];long long ans[13];long long fun(long long s 阅读全文

posted @ 2011-05-07 13:36 宇宙吾心 阅读(283) 评论(0) 推荐(0)

导航