摘要: 1. 动态规划是自底向上 ,备忘录方法是自顶向下。2、动态规划每个子问题都要解一次,但不会求解重复子问题;备忘录方法只解哪些确实需要解的子问题;递归方法每个子问题都要解一次,包括重复子问题。 阅读全文
posted @ 2014-10-01 17:07 linyx 阅读(1437) 评论(0) 推荐(0) 编辑
摘要: 对齐。 1 #include 2 using namespace std; 3 4 struct S1 { 5 int a; 6 char b; 7 char c; 8 }; 9 10 struct S2 {11 int a;12 char b;13 ... 阅读全文
posted @ 2014-10-01 16:59 linyx 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 注意空域。unsigned默认是4个字节。 1 #include 2 3 using namespace std; 4 struct B1{ 5 unsigned a:4; 6 unsigned b:4; 7 }; 8 9 struct B2{10 unsigned a... 阅读全文
posted @ 2014-10-01 16:49 linyx 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 后面两种写法很巧妙。一种利用位域,一种利用取余。这里如果不用unsigned char来做位域的话,大小就为4. unsigned char才符合题目要求。 1 void chess1() { 2 struct { 3 unsigned char a:4; 4 ... 阅读全文
posted @ 2014-10-01 16:25 linyx 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 有一根长为L的平行于x轴的细木杆,其左端点的x坐标为0(故右端点的x坐标为L)。刚开始时,上面有N只蚂蚁,第i(1≤i≤N)只蚂蚁的横坐标为xi(假设xi已经按照递增顺序排列),方向为di(0表示向左,1表示向右),每个蚂蚁都以速度v向前走,当任意两只蚂蚁碰头时,它们会同时调头朝相反方向走,速度不变... 阅读全文
posted @ 2014-10-01 01:17 linyx 阅读(789) 评论(0) 推荐(0) 编辑