huangriq

导航

2012年4月14日 #

poj 1191(棋盘分割)

摘要: View Code 1 #include<iostream> 2 #include<stdio.h> 3 #include<string.h> 4 #include<algorithm> 5 #include<cmath> 6 using namespace std; 7 double col[10][10],s[10][10][10][10],var[10][10][10][10][20]; 8 int main() 9 {10 double n,a;11 double sum=0;12 memset(col,0,sizeof(co 阅读全文

posted @ 2012-04-14 15:15 huangriq 阅读(152) 评论(0) 推荐(0)

poj 3280(Cheapest Palindrome)

摘要: View Code #include<iostream>#include<stdio.h>#include<string.h>using namespace std;int add[26],det[26],dp[2020][2020]={0};char str[2020];int dfs(int x,int y){ if(x>=y)return 0; if(str[x]==str[y]) { if(!dp[x+1][y-1])dp[x+1][y-1]=dfs(x+1,y-1); return dp[x+1][y-1]; } else ... 阅读全文

posted @ 2012-04-14 15:14 huangriq 阅读(167) 评论(0) 推荐(0)

HDU 3593(The most powerful force)

摘要: View Code #include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define N 10010struct edge{ int to,next;}e[N*10];int pre[N*10],c[N*10],v[N*10],dp[550][N];/*void add(int a,int b){ e[cnt].to=b; e[cnt].next=pre[a]; pre[a]=cnt++;}*/void dfs(i 阅读全文

posted @ 2012-04-14 15:12 huangriq 阅读(240) 评论(0) 推荐(0)

poj 1742(Coins)

摘要: View Code #include<iostream>#include<stdio.h>#include<string.h>using namespace std;int val[110],cnt[110],b[100010],use[100010];int main(){ int n,m; while(scanf("%d%d",&n,&m)) { memset(b,0,sizeof(b)); if(n==0&&m==0)break; for(int i=1;i<=n;i++) scanf(&quo 阅读全文

posted @ 2012-04-14 15:10 huangriq 阅读(180) 评论(0) 推荐(0)

poj 1184(聪明的打字员)

摘要: View Code #include<iostream>#include<queue>#include<cmath>#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;struct node{ int w,deep,pos,flag;};int pow(int a,int b){ if(b==0)return 1; if(b%2==1)return a*pow(a*a,b/2); else return pow(a*a,b/2) 阅读全文

posted @ 2012-04-14 15:04 huangriq 阅读(323) 评论(0) 推荐(0)

poj 2449(Remmarguts' Date)

摘要: View Code 1 #include<stdio.h> 2 #include<iostream> 3 #include<queue> 4 #include<string.h> 5 using namespace std; 6 #define inf 0x7ffffff 7 #define N 100010 8 #define M 1010 9 struct edge{ 10 int w,to,next; 11 }e1[N],e2[N]; 12 struct node{ 13 int w,u; 14 bool operator <(con 阅读全文

posted @ 2012-04-14 14:59 huangriq 阅读(142) 评论(0) 推荐(0)

poj 1837(blance)

摘要: 该题为一道简单的01背包,本题解用滚动队列(叫栈也可)稍微进行了些优化,由于该背包出现了负数,我们用10000作为表示平衡点View Code 1 #include<iostream> 2 #include<stdio.h> 3 #include<string.h> 4 using namespace std; 5 int l[22],w[22],q[2][20002],b[2][20002]; 6 int main() 7 { 8 int c,g; 9 while(scanf("%d%d",&c,&g)!=EOF)10 阅读全文

posted @ 2012-04-14 14:49 huangriq 阅读(147) 评论(0) 推荐(0)

poj 1077(八数码)

摘要: 八数码问题有多种解法,本题解采用的是双向搜索View Code 1 #include<iostream> 2 #include<map> 3 #include<string> 4 #include<queue> 5 #include<stdio.h> 6 #include<string.h> 7 using namespace std; 8 structnode{ 9 stringsx; 10 int pos; 11 }; 12 13 int dir[4]={-3,1,3,-1}; 14 char ch1[4]={' 阅读全文

posted @ 2012-04-14 12:06 huangriq 阅读(172) 评论(0) 推荐(0)