书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

2011年10月18日

Stack解决——括号匹配

摘要: Description题意描述: 在算术表达式中,除了加、减、乘、除等运算外,往往还有括号。包括有大括号{},中括号[],小括号(),尖括号<>等。 对于每一对括号,必须先左边括号,然后右边括号;如果有多个括号,则每种类型的左括号和右括号的个数必须相等;对于多重括号的情形,按运算规则,从外到内的括号嵌套顺序为:大括号->中括号->小括号->尖括号。例如,{[()]},{()},{{}}为一个合法的表达式,而([{}]),{([])},[{<>}]都是非法的。Input文件的第一行为一个整数n(1≤n≤100),接下来有n行仅由上述四类括号组成的括号表达 阅读全文

posted @ 2011-10-18 21:42 More study needed. 阅读(784) 评论(0) 推荐(0) 编辑

感悟Floyd

摘要: 今天做了一道Jump题目,本以为是一道搜索的题目,没想到竟然用Floyd就轻松的解决了。 先来看看这个题目吧! Description There is n pillar, their heights are (A1,A2,A3,…An).you can jump at the top of the pillars. But you will lose abs(a[j]-a[i])*abs(j-i) power when you jump from i-th pillar to j-th pillar. At first you have m power. Can you jump f... 阅读全文

posted @ 2011-10-18 11:22 More study needed. 阅读(886) 评论(0) 推荐(1) 编辑

Floyd算法解决 Jump

摘要: DescriptionThere is n pillar, their heights are (A1,A2,A3,…An).you can jump at the top of the pillars. But you will lose abs(a[j]-a[i])*abs(j-i) power when you jump from i-th pillar to j-th pillar. At first you have m power. Can you jump from s-th pillar to e-th pillar.InputThe input consists of sev 阅读全文

posted @ 2011-10-18 11:03 More study needed. 阅读(268) 评论(0) 推荐(0) 编辑

导航

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!