随笔分类 -  动态规划—数位dp

摘要:D. Bookshelves 注意:sum[ ii ]表示第 ii 块的所有数字和,因为有序,实际上就是一个区间和。 题解:二进制枚举答案ans,怎么枚举呢?从高位到低位放1,如果这个序列划分成m块后,能够sum[1] & sum[2] & ···· & sum[m] = ans,那么这位能够放1。 阅读全文
posted @ 2018-05-30 17:12 天之道,利而不害 阅读(170) 评论(0) 推荐(0) 编辑
摘要:题解:dp[ i ][ j ][ k ]表示第i个位置,支点是j,支点左右两边的重量之差是k。当k==0时,说明这个数是Balanced Number。充分利用了回溯这个过程! 阅读全文
posted @ 2017-09-21 16:44 天之道,利而不害 阅读(196) 评论(0) 推荐(1) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int maxn=1e4+5; 8 9 int A,B,sum; 10 int num[40],dp[40][maxn]; 11 12 int F(int x){ 13 if(x==0) return 0;... 阅读全文
posted @ 2017-09-21 11:38 天之道,利而不害 阅读(1000) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int n,m; 8 int num[40],dp[40][80]; //表示第i个位置,0的个数减去1的个数的差值 9 10 int DFS(int pos,int res,bool ok,bool F){ 11 ... 阅读全文
posted @ 2017-09-20 23:25 天之道,利而不害 阅读(243) 评论(0) 推荐(0) 编辑
摘要:杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。不吉利的数字为所有含有4或62的号码。例如:62315 73418 88914都属 阅读全文
posted @ 2017-09-17 17:31 天之道,利而不害 阅读(394) 评论(0) 推荐(0) 编辑
摘要:An integer is divisible by 3 if the sum of its digits is also divisible by 3. For example, 3702 is divisible by 3 and 12 (3+7+0+2) is also divisible b 阅读全文
posted @ 2017-09-13 22:18 天之道,利而不害 阅读(269) 评论(0) 推荐(0) 编辑
摘要:A bit is a binary digit, taking a logical value of either 1 or 0 (also referred to as "true" or "false" respectively). And every decimal number has a 阅读全文
posted @ 2017-09-10 15:35 天之道,利而不害 阅读(216) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示