随笔分类 -  dp动态规划

摘要:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。 例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。 对于pre ,每次pop的数据,就是最上方的root 对于t 阅读全文
posted @ 2021-07-16 11:44 zhang_upstar 阅读(44) 评论(0) 推荐(0)
摘要:Do you know what is called ``Coprime Sequence''? That is a sequence consists of nnpositive integers, and the GCD (Greatest Common Divisor) of them is 阅读全文
posted @ 2018-04-28 21:29 zhang_upstar 阅读(186) 评论(0) 推荐(0)
摘要:急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。 请问:你用有限的资金最多能采购多少公斤粮食呢? 后记: 人生是一个充满了变数的生命过程,天灾、人祸、病痛是 阅读全文
posted @ 2017-04-17 22:00 zhang_upstar 阅读(149) 评论(0) 推荐(0)
摘要:最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或 阅读全文
posted @ 2017-04-17 21:46 zhang_upstar 阅读(266) 评论(0) 推荐(0)
摘要:Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s 阅读全文
posted @ 2017-04-13 21:27 zhang_upstar 阅读(152) 评论(0) 推荐(0)
摘要:The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become t 阅读全文
posted @ 2017-04-13 13:20 zhang_upstar 阅读(177) 评论(0) 推荐(0)
摘要:Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irrever 阅读全文
posted @ 2017-04-12 19:55 zhang_upstar 阅读(173) 评论(0) 推荐(0)
摘要:Problem Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜 阅读全文
posted @ 2017-04-11 11:35 zhang_upstar 阅读(315) 评论(0) 推荐(0)
摘要:昨天晚上的rank彻底废了。。一个星期没敲代码完全没手感。作为总结,贴一道昨天浪费了我两小时的dp。http://acm.dirring.com/problem.php?cid=1003&pid=3 问题 D: Dirring love 音乐 题目描述 上个学期,Dirring给自己的手机升级了安卓 阅读全文
posted @ 2016-10-05 11:05 zhang_upstar 阅读(136) 评论(0) 推荐(0)