上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 36 下一页

2011年5月12日

poj 2836

摘要: 因为要面积最小,一定是以每次覆盖两个点为主,并让这两个点在矩形的对角。此题不可以出现面积为0的矩形,所以当出现x[i]==x[j]或者y[i]==y[j]时,让它为0的这边的边长变成1。代码:#include<iostream>#include<fstream>using namespace std;int n,m;int x[16],y[16];int state[300],value[300];void ok(int s,int t){ int i,j,k; k=(1<<(s-1))+(1<<(t-1)); for(i=1;i<=n;i 阅读全文

posted @ 2011-05-12 15:55 宇宙吾心 阅读(506) 评论(0) 推荐(0)

poj 2411

摘要: 经典状态dp状态复用了代码:#include<iostream>#include<fstream>#include<cmath>using namespace std;int n,m;long long dp[12][2048];int ok(int s){ int i,j,k; for(i=0;i<m;) { j=s&(1<<i); if(j>0) { if(i+1>=m) return 0; if((s&(1<<(1+i)))==0) return 0; i+=2; } else i++; } r 阅读全文

posted @ 2011-05-12 15:00 宇宙吾心 阅读(241) 评论(0) 推荐(0)

poj 1691

摘要: dfs代码:#include<iostream>#include<fstream>using namespace std;int n;struct e{ int x1,y1,x2,y2,c;};e a[16];struct ee{ int data; ee *next;};ee edge[16];int ans;int d[16];int v[16];void solve(int num,int value,int color){ int i,j,k; if(value>ans) return; if(num==n) { ans=value; return; } 阅读全文

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

poj 1185

摘要: 经典状态dp代码:#include<iostream>#include<fstream>#include<cmath>using namespace std;int n,m;char map[101][11];int state[101][1024];int num[101];int value[1024];int maxx;int ok(int s,int t){ int i,j,k; for(i=0;i<m;) { j=t&(1<<i); if(j) { if(map[s][i+1]=='H') return 0 阅读全文

posted @ 2011-05-12 10:36 宇宙吾心 阅读(902) 评论(0) 推荐(0)

2011年5月11日

poj 2137

摘要: 题目大意: 农夫FJ想把他所有的牛在它们吃草的时候用一根绳子连起来(就是1-2-3-1按顺序连接起来),每头牛有若干个吃草的位置,它们必须要在这些位置吃草。用绳子连接两头牛需要绳子的长度公式为 Sqrt( Sqr( x1-x2 ) + Sqr( y1-y2 ) ) ,农夫FJ希望需要的那根绳子长度最短,他需要你帮他求出这个最短的长度是多少。代码:#include<iostream>#include<fstream>#include<cmath>using namespace std;int n;int num[101];double x[101][41];d 阅读全文

posted @ 2011-05-11 18:17 宇宙吾心 阅读(328) 评论(0) 推荐(0)

poj 2231

摘要: 水题代码:#include<iostream>#include<fstream>using namespace std;long long n;long long a[10001];int cmp(const void *a,const void *b){ return *(long long*)a-*(long long *)b;}void read(){// ifstream cin("in.txt"); long long i,j,k; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; lo 阅读全文

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

poj 2241

摘要: 题意:已知有n(n<30)种类型的block,以及它们的长宽高,每种类型的block都有无限多个。问如果把他们叠起来(上面block的底面的长宽,必须比下面的block的底面长宽都短),最高能有多高。代码:#include<iostream>#include<fstream>using namespace std;int n;struct e{ int s,t,h;};e a[100];int cmp(const void *a,const void *b){ return (*(e *)a).s-(*(e *)b).s;}int dp[101];void rea 阅读全文

posted @ 2011-05-11 15:59 宇宙吾心 阅读(389) 评论(0) 推荐(0)

poj 2264

摘要: 水题,定义好状态代码:#include<iostream>#include<fstream>using namespace std;char c1[110],c2[110];int dp[110][110];void print(int s,int t){ int i,j,k; if(s==0&&t==0) return; if(s==0) { for(i=0;i<t;i++) cout<<c2[i]; return; } if(t==0) { for(i=0;i<s;i++) cout<<c1[i]; return; 阅读全文

posted @ 2011-05-11 15:34 宇宙吾心 阅读(263) 评论(0) 推荐(0)

poj 2479

摘要: dp代码:#include<iostream>#include<fstream>using namespace std;int n;int l[50003],r[50003];int a[50003];void read(){// ifstream cin("in.txt"); int i,j,k; scanf("%d",&k); while(k--) { scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&a[i]) 阅读全文

posted @ 2011-05-11 14:55 宇宙吾心 阅读(261) 评论(0) 推荐(0)

poj 3519

摘要: dp代码:#include<iostream>#include<fstream>using namespace std;double dp[111][111];int mark[101];int l,b;int n,m;int ok(int s,int t){ int i,j,k; k=s+t; while(1) { if(k>n) k=2*n-k; else if(k<0) k=-k; else break; } if(mark[k]==2) k=0; return k;}void read(){// ifstream cin("in.txt&q 阅读全文

posted @ 2011-05-11 13:53 宇宙吾心 阅读(275) 评论(0) 推荐(0)

上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 36 下一页

导航