2011年4月23日

poj 2313

摘要: 贪心。代码:#include<iostream>#include<fstream>using namespace std;int b[101],a[101];int n;int cmp(const void *a,const void *b){ return *(int*)a-*(int*)b;}int solve(int n1,int n2,int n3){ int c[3]; c[0]=n1;c[1]=n2;c[2]=n3; qsort(c,3,sizeof(int),cmp); return c[1];}void read(){// ifstream cin(&q 阅读全文

posted @ 2011-04-23 19:26 宇宙吾心 阅读(246) 评论(0) 推荐(0)

poj 1907

摘要: 贪心。代码:#include<iostream>#include<fstream>using namespace std;int n,m,num;struct e{ char c[20]; int sum;};e a[101];int cmp(const void *a,const void *b){ e s,t; s=*(e*)a;t=*(e*)b; if(s.sum!=t.sum) return s.sum-t.sum; else return strcmp(s.c,t.c);}void read(){// ifstream cin("in.txt&quo 阅读全文

posted @ 2011-04-23 16:56 宇宙吾心 阅读(270) 评论(0) 推荐(0)

poj 1456

摘要: 贪心+并查集。代码:#include<iostream>#include<fstream>using namespace std;int n;struct e{ int s,t;};int cmp(const void *a,const void *b){ return (*(e *)b).s-(*(e *)a).s;}e p[10001];int f[10001];void init(){ int i; for(i=0;i<=10000;i++) { f[i]=i; }}int father(int s){ if(s!=f[s]) f[s]=father(f[s 阅读全文

posted @ 2011-04-23 16:11 宇宙吾心 阅读(272) 评论(0) 推荐(0)

poj 1230

摘要: 贪心。代码:#include<iostream>#include<fstream>using namespace std;int a[101][2];int b[101];int n,m;void read(){// ifstream cin("in.txt"); int i,j,k,s,t,maxx,ans,maxx1; cin>>k; while(k--) { cin>>n>>m; ans=0; maxx=0; for(i=1;i<=n;i++) { cin>>a[i][0]>>s 阅读全文

posted @ 2011-04-23 15:24 宇宙吾心 阅读(427) 评论(0) 推荐(0)

导航