A - Serval and Bus It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for…
D - Aggressive cows 农夫 John 建造了一座很长的畜栏,它包括N (2 <= N <= 100,000)个隔间,这些小隔间依次编号为x1,...,xN (0 <= xi <= 1,000,000,000). 但是,John的C (2 <= C <= N)头牛们并不喜欢这种布局,而且几头牛放在一个隔间里,他们就要发生争斗.为了不让牛互相伤害.John决定自己给牛分配隔间,使任意两头牛之间的最小距离尽可能的大,那么,这个最大的最小距离是什么呢? Inp…
B - Maximal Continuous Rest Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day - it is a sequence a1,a2,-,an (each ai is either 0 or 1), where ai=0 if Polycarp works during the i-t…
A - Game 23 Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves. Print the number of moves needed to transform n t…
浅入动态规划 dynamic programming is a method for solving a complex problem by breaking it down into a collection of simpler subproblems. 最近进行动态规划的学习,看到了一个很好的例子,现在把它记录下来仅供自我知识梳理 1. 从一个生活问题谈起 作者:阮行止 先来看看生活中经常遇到的事吧--假设您是个土豪,身上带了足够的1.5.10.20.50.100元面值的钞票.现在您的目…