06 2011 档案

poj 2436
摘要:dfs代码:#include<iostream>#include<fstream>using namespace std;int cow[1001];int n,d,k;int ans;int b[16];void solve(int s,int t,int p){ int i,j; if(d-s+1<k-t) return; if(t==k) { j=0; for(i=1;i<=n;i++) if(cow[i]==(cow[i]&p)) j++; if(j>ans) ans=j; return; } solve(s+1,t+1,p|(1< 阅读全文

posted @ 2011-06-26 21:53 宇宙吾心 阅读(170) 评论(0) 推荐(0)

poj 3411
摘要:有意思的dfs代码:#include<iostream>#include<fstream>#include<vector>using namespace std;struct node{ int c,p,r,data;};vector<node> edge[11];int n,m;int v[11];int ans;void solve(int s,int w){ int i,j,k; if(w>ans) return; if(s==n) { ans=w; return ; } for(i=0;i<edge[s].size();i++ 阅读全文

posted @ 2011-06-26 21:18 宇宙吾心 阅读(322) 评论(0) 推荐(0)

poj 2677
摘要:TSP#include<iostream>#include<fstream>#include<cmath>using namespace std;double dp[101][101];int x[101],y[101];double ok(int s,int t){ return sqrt(1.*(x[s]-x[t])*(x[s]-x[t])+(y[s]-y[t])*(y[s]-y[t]));}int n;void read(){// ifstream cin("in.txt"); int i,j,k; while(cin>> 阅读全文

posted @ 2011-06-15 17:33 宇宙吾心 阅读(262) 评论(0) 推荐(0)

poj 1952
摘要:dp#include<iostream>#include<fstream>using namespace std;int len[5001],time[5001];int a[5001];int n;void read(){// ifstream cin("in.txt"); int i,j,k; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=n;i++) { len[i]=1; time[i]=1; } for(i=1;i<=n;i++) for(j=i-1 阅读全文

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

poj 1862
摘要:贪心#include<iostream>#include<fstream>#include<cmath>#include<queue>using namespace std;int n;void read(){// ifstream cin("in.txt"); int i,j,k; double s,t; cin>>n; priority_queue<double> q; for(i=1;i<=n;i++) { cin>>j; t=j; q.push(t); } while(1) { 阅读全文

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

poj 2065
摘要:#include<iostream>#include<fstream>#include<cmath>using namespace std;int n,m,p;int map[74][74];int find(int s,int t){ s=(s%p+p)%p; t=(t%p+p)%p; for(int i=0;i<p;i++) if((i*t)%p==s) return i;}void solve(){ int i,j,k,s,t,a,b; j=0; for(i=0;i<n&&j<m;i++,j++) { s=0;t=0; 阅读全文

posted @ 2011-06-02 11:06 宇宙吾心 阅读(242) 评论(0) 推荐(0)

poj 1611
摘要:#include<iostream>#include<fstream>using namespace std;int f[30001],rank[30001];int n,m;void init(){ int i; for(i=0;i<=n;i++){ f[i]=i; rank[i]=0; }}int father(int s){ if(s!=f[s]) f[s]=father(f[s]); return f[s];}void unionset(int s,int t){ int i=father(s); int j=father(t); if(rank[i]&l 阅读全文

posted @ 2011-06-02 10:36 宇宙吾心 阅读(189) 评论(0) 推荐(0)

poj 1789
摘要:#include<iostream>#include<fstream>#include<queue>using namespace std;char c[2001][8];int map[2001][2001];int ok(int s,int t){ int j=0; for(int i=0;i<7;i++) { if(c[s][i]!=c[t][i]) j++; } return j;}int d[2001];int v[2001];int n;void solve(){ int i,j,k; for(i=1;i<=n;i++) d[i]=m 阅读全文

posted @ 2011-06-02 10:26 宇宙吾心 阅读(238) 评论(0) 推荐(0)

poj 2139
摘要:#include<iostream>#include<fstream>using namespace std;int map[301][301];int n,m;int a[301];void read(){// ifstream cin("in.txt"); int i,j,k,s,t; cin>>n>>m; memset(map,-1,sizeof(map)); for(i=1;i<=m;i++) { cin>>k; for(j=1;j<=k;j++) cin>>a[j]; for(s= 阅读全文

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

poj 2349
摘要:#include<iostream>#include<fstream>#include<cmath>using namespace std;int n,m;struct e{ int s,t; double w;};e edge[250001];int x[501],y[501];int top;void add(int s,int t,double w){ edge[++top].s=s; edge[top].t=t; edge[top].w=w;};int cmp(const void *a,const void *b){ if( (*(e*)a).w& 阅读全文

posted @ 2011-06-01 17:02 宇宙吾心 阅读(275) 评论(0) 推荐(0)

poj 2075
摘要:#include<iostream>#include<fstream>using namespace std;struct e{ int s,t; double w;};e edge[250001];int n,m;char c[501][30];int cmp(const void *a,const void *b){ if ((*(e*)a).w>(*(e*)b).w) return 1; return -1;}int top;void add(int s,int t,double w){ edge[++top].s=s; edge[top].t=t; edg 阅读全文

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

导航