摘要: 我的做法是,用栈把能stable的去掉,把剩下的左空号和右括号的个数分别算出来n,m,n和m肯定同奇同偶如果是偶数的话,}}{{——>{}{},2次操作:n/2+m/2;如果是奇数的话,}}}{——>{}{},3次操作:(n-1)/2+(m-1)/2+2;View Code #include <stdio.h>#include <string.h>int n;char stack[2005];void Push(char ch){ stack[++n]=ch;}char Pop(){ if(n-1==-1)return '0'; return 阅读全文
posted @ 2011-11-14 13:26 104_gogo 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 0-1背包真是没想到..View Code #include <stdio.h>int dp[25][15005];int main(){ int C,G,i,j,k,c[25],g[25]; scanf("%d%d",&C,&G); for (i=0;i<C;i++)scanf("%d",&c[i]); for (i=1;i<=G;i++)scanf("%d",&g[i]); dp[0][7500]=1; for (i=1;i<=G;i++) { for (j=0;j&l 阅读全文
posted @ 2011-11-14 10:43 104_gogo 阅读(147) 评论(0) 推荐(0) 编辑