10 2013 档案

摘要:题目:http://poj.org/problem?id=1942题意:给定一个矩形网格的长m和高n,其中m和n都是unsigned int32类型,一格代表一个单位,就是一步,求从左下角到右上角有多少种走法,每步只能向上或者向右走题解:就是 上和 右的排列。用c(m,n)=n!/m!*(n-m)!;最重要的是算阶乘。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 unsigned comb(unsigned m,unsigned n) 7 { 8 unsigned a,b; 9 double cnt=... 阅读全文
posted @ 2013-10-30 20:30 水门 阅读(174) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1159 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int mmin(int a,int b) 7 { 8 return a>b?b:a; 9 }10 short int d[5010][5010];11 int main()12 {13 int n,i,j;14 char s[5010];15 memset(d,0,sizeof(d));16 cin>>n;17 for(i=1; i>s[i];19 ... 阅读全文
posted @ 2013-10-28 21:32 水门 阅读(156) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1080题意:比较两个基因序列,测定它们的相似度,将两个基因排成直线,如果需要的话插入空格,使基因的长度相等,然后根据那个表格计算出相似度。题解:考虑f[i][j]:①s1取第i个,s2取第j个,f[i][j] = f[i-1][j-1]+value[m(s1[i])][m(s2[j])];②s1取第i个,s2用’-’,f[i][j] = f[i][j-1]+value[m(s1[i])][m(‘-’)];③s1用’-’,s2取第j个,f[i][j] = f[i-1][j]+value[m(‘-’)][m(s2[j])];f[i][j] 阅读全文
posted @ 2013-10-28 20:44 水门 阅读(205) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1836题意:最长上升子序列问题, 站队,求踢出最少的人数后,使得队列里的人都能看到 左边的无穷远处 或者 右边的无穷远处。代码O(n^2): 1 #include 2 #include 3 using namespace std; 4 5 int main() 6 { 7 int n,i,j,d1[1100],d2[1100],mx; 8 double a[1100]; 9 cin>>n;10 for(i=1; i>a[i];12 d1[1]=1;13 for(i=2; i0&&d1[... 阅读全文
posted @ 2013-10-26 19:50 水门 阅读(163) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=2533题意:最长上升子序列。。。。 以前做过,课本上的思想 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int main() 8 { 9 int m,a[1100];10 int d[1100],i,j,n;11 int nmax;12 cin>>n;13 for(i=1; i>a[i];16 }17 d[1]=1;18 for(i=1; i... 阅读全文
posted @ 2013-10-24 21:01 水门 阅读(154) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1260题意:给出几类珍珠,以及它们的单价,要求用最少的钱就可以买到相同数量的,相同(或更高)质量的珍珠。珍珠的替代必须是连续的,不能跳跃替代(这个不难证明,因为假如用第i+2类去替代第i类珍珠,会使最终的支付价格降低,那么用第i+1类去替代第i类珍珠会使最终的支付价格更加低) 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int main() 8 { 9 int t,i,j,num,minn,sum;10 int d[11... 阅读全文
posted @ 2013-10-24 19:41 水门 阅读(180) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1850题意:按给定的规则给字母编号。一个很简单的题目,但是却做了好久。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 1 #include 2 #include 3 #include 4 using namespace std; 5 int c[30][30]; 6 void init()//用杨辉三角的方法求组合数,C(n,m) 7 { 8 int i,j; 9 for(i=0; i>s;21 22 k=strlen(s);23 for(i=0; ... 阅读全文
posted @ 2013-10-18 20:20 水门 阅读(174) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1276题意:费用和价值相同的多重背包。以前看背包的时候做过,今天又做了一遍。二进制优化代码 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int _max(int ... 阅读全文
posted @ 2013-10-14 21:23 水门 阅读(178) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1837题意:求平衡状态, c个位置,g个物体重量,求有多少种平衡状态。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() 7 { 8 int c,g,d[25][15000],h[25],w[25];//d 的第一个代表物品个数,第二个代表现在的平衡状态,>7500为向右偏 9 cin>>c>>g;10 for(int i=1; i>h[i];12 for(int i=1; i>w[i];14 mems 阅读全文
posted @ 2013-10-14 19:09 水门 阅读(161) 评论(0) 推荐(0)