2011年5月6日

poj 3257

摘要: dp代码:#include<iostream>#include<fstream>using namespace std;int l,n,b;struct e{ int w,x,f,c;};e a[10001];int dp[1001][1001];int cmp(const void *a,const void *b){ e *s=(e *)a; e *t=(e *)b; return s->x-t->x;}void read(){// ifstream cin("in.txt"); int i,j,k; cin>>l> 阅读全文

posted @ 2011-05-06 21:49 宇宙吾心 阅读(227) 评论(0) 推荐(0)

poj 3267

摘要: 题意:求最少去掉多少字母,能使句子可由单词表中的单词连成。代码:#include<iostream>#include<fstream>using namespace std;char c[310];char a[601][30];int dp[301];int n,m;int ok(int s,int t){ int i,j,k; j=strlen(a[t])-1; for(i=s;j>=0&&i>=0;i--) if(c[i]==a[t][j]) { j--; if(j==-1) return i; } return -1;} void r 阅读全文

posted @ 2011-05-06 21:00 宇宙吾心 阅读(266) 评论(0) 推荐(0)

poj 3298

摘要: 贪心代码:#include<iostream>#include<fstream>using namespace std;int a[30001];int n;void read(){// ifstream cin("in.txt"); int i,j,k; int cas; cin>>cas; while(cas--) { cin>>n; for(i=1;i<=n;i++) cin>>a[i]; j=1;k=a[1];i=2; int ans=1; while(i<=n) { if(k<a[i]& 阅读全文

posted @ 2011-05-06 17:31 宇宙吾心 阅读(167) 评论(0) 推荐(0)

poj 3342

摘要: 宴会邀请,求最多能邀请多少人? 条件是具有主仆关系的人不能同时被邀请代码:#include<iostream>#include<fstream>#include<string>#include<map>using namespace std;int n;int g[201][201];int dp[201][2];string str1,str2;void solve(int s){ int i,j,k; dp[s][0]=0; dp[s][1]=1; for(i=1;i<=n;i++) if(g[s][i]) { solve(i); dp 阅读全文

posted @ 2011-05-06 17:09 宇宙吾心 阅读(513) 评论(1) 推荐(0)

poj 3356

摘要: 题意:给出两个字符串x和y,要求使用最少的操作使得X变为y,求解该最少操作数.#include<iostream>#include<fstream>using namespace std;int dp[1001][1001];char a[1010],b[1010];int n1,n2;void read(){// ifstream cin("in.txt"); int i,j,k; while(cin>>n1>>a>>n2>>b) { for(i=1;i<=n1;i++) dp[i][0]=i; 阅读全文

posted @ 2011-05-06 16:06 宇宙吾心 阅读(508) 评论(0) 推荐(0)

poj 3638

摘要: 一个地图软件需要需要存储h个房子的坐标信息,但为节约存储空间可以只存储其中的m个房子的坐标信息其他房子的坐标信息可以由插值得到。问怎样选择这个m个房子,使得所有房子的插值误差之和最小, 输出最小的插值误差均值。n^3 dp代码:#include<iostream>#include<fstream>using namespace std;int n,m;double dp[201][201];double a[201];double w[201][201];double fabs(double s){ if(s<0) return -s; else return s 阅读全文

posted @ 2011-05-06 15:41 宇宙吾心 阅读(291) 评论(0) 推荐(0)

导航