摘要:
Description題意描述: 在算術表達式中,除了加、減、乘、除等運算外,往往還有括號。包括有大括號{},中括號[],小括號(),尖括號<>等。 對于每一對括號,必須先左邊括號,然后右邊括號;如果有多個括號,則每種類型的左括號和右括號的個數必須相等;對于多重括號的情形,按運算規則,從外到內的括號嵌套順序為:大括號->中括號->小括號->尖括號。例如,{[()]},{()},{{}}為一個合法的表達式,而([{}]),{([])},[{<>}]都是非法的。Input文件的第一行為一個整數n(1≤n≤100),接下來有n行僅由上述四類括號組成的括號表達
閱讀全文
摘要:
今天做了一道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...
閱讀全文
摘要:
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
閱讀全文