摘要: 简单模拟代码:#include #include using namespace std;class Solution {public: bool isAlpha(char &in) { if(in >= 'a' && in = 'A' && in = '0' && in <= '9') return true; return false; } bool isPalindrome(string s) { int l = 0, h = s.size()-1; boo 阅读全文
posted @ 2013-11-28 22:58 SangS 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 题意: 阅读全文
posted @ 2013-11-28 22:40 SangS 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 思路:1. 每个板子有左右两端, dp[i][0], dp[i][1] 分别记录左右端到地面的时间2. 从下到上递推计算, 上一层的板子必然会落到下面的某一层板子上, 或者地面上总结:1. 计算每个板子的 dp[i][0/1] 仅需考虑该板子的直接前驱即可2. 动规的思想并不很明显3. 代码中, 两个板子相对位置的判断特别精髓4. 将地面和初始状态都抽象成一块板子代码:#include #include using namespace std;class board {public: int x1, x2, h; board(int _x1, int _x2, int _h):x1(_x1), 阅读全文
posted @ 2013-11-28 11:24 SangS 阅读(230) 评论(0) 推荐(0) 编辑
摘要: DescriptionThere is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village is identified with a single integer coordinate. There are no two villages in the same position. The distance between two positions is the absolu 阅读全文
posted @ 2013-11-28 11:22 SangS 阅读(542) 评论(0) 推荐(0) 编辑