上一页 1 ··· 26 27 28 29 30
摘要: 题目描述:Find a longest common subsequence of two strings.输入:First and second line of each input casecontain two strings of lowercase character a…z. There are no spaces before, inside or after the strings. Lengths of strings do not exceed 100.输出:For each case, output k – the length of a longest common s 阅读全文
posted @ 2012-07-30 22:36 Eason Liu 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 题目描述:二叉树的前序、中序、后序遍历的定义:前序遍历:对任一子树,先访问跟,然后遍历其左子树,最后遍历其右子树;中序遍历:对任一子树,先遍历其左子树,然后访问根,最后遍历其右子树;后序遍历:对任一子树,先遍历其左子树,然后遍历其右子树,最后访问根。给定一棵二叉树的前序遍历和中序遍历,求其后序遍历(提示:给定前序遍历与中序遍历能够唯一确定后序遍历)。 输入: 两个字符串,其长度n均小于等于26。第一行为前序遍历,第二行为中序遍历。二叉树中的结点名称以大写... 阅读全文
posted @ 2012-07-25 19:02 Eason Liu 阅读(3597) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 如果A,B是C的父母亲,则A,B是C的parent,C是A,B的child,如果A,B是C的(外)祖父,祖母,则A,B是C的 grandparent,C是A,B的grandchild,如果A,B是C的(外)曾祖父,曾祖母,则A,B是C的great- grandparent,C是A,B的great-grandchild,之后再多一辈,则在关系上加一个great-。输入: 输入包含多组测试用例,每组用例首先包含2个整数n(0#include #include #include using namespace std;map fa;char x[3];int m,n;inline int 阅读全文
posted @ 2012-07-25 17:01 Eason Liu 阅读(368) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 读入两个不超过25位的火星正整数A和B,计算A+B。需要注意的是:在火星上,整数不是单一进制的,第n位的进制就是第n个素数。例如:地球上的10进 制数2,在火星上记为“1,0”,因为火星个位数是2进制的;地球上的10进制数38,在火星上记为“1,1,1,0”,因为火星个位数是2进制的,十位 数是3进制的,百位数是5进制的,千位数是7进制的……输入: 测试输入包含若干测试用例,每个测试用例占一行,包含两个火星正整数A和B,火星整数的相邻两位数用逗号分隔,A和B之间有一个空格间隔。当A或B为0时输入结束,相应的结果不要输出。输出: 对每个测试用例输出1行,即火星表示法的A+B的值。样例 阅读全文
posted @ 2012-07-25 16:47 Eason Liu 阅读(485) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Today, facing the rapid development of business, SJTU recognizes that more powerful calculator should be studied, developed and appeared in future market shortly. SJTU now invites you attending such amazing research and development work. In most business applications, the top three useful calc 阅读全文
posted @ 2012-07-25 16:35 Eason Liu 阅读(369) 评论(0) 推荐(0) 编辑
上一页 1 ··· 26 27 28 29 30