
剪枝
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
素数环(dfs&&STL做法)HDU - 1016
这题第一思路显然dfs,但是最近想了一下可以用next_permutation做,结果TLE了,究其原因,就是深搜的时候剪枝做的比较好,所以运行的时间一对比(样例是n=18),会发现dfs的解法程序在不停的输出数据,但是STL的却仅仅是在闪光标。 得结论:有的题剪枝的十分优雅(比如这题,如果1 2 判断不成立,那么第二个数放2这一大支直接剪掉了),便不能用next_permutati...原创 2018-06-07 22:22:39 · 264 阅读 · 0 评论 -
【HDU - 1856】 More is better(并查集)(还需要空间优化。。)
题干:Mr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the better it will be. Of course there are certain requirements. Mr Wang selected a ro...原创 2018-07-15 23:39:20 · 231 阅读 · 0 评论 -
【HDU - 1518】Square (经典的dfs + 剪枝)
题干:Given a set of sticks of various lengths, is it possible to join them end-to-end to form a square? InputThe first line of input contains N, the number of test cases. Each test case begins wit...原创 2018-09-11 16:22:45 · 434 阅读 · 0 评论 -
【HDU - 1455】Sticks (dfs + 剪枝)
题干:George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had...原创 2018-09-12 09:42:31 · 247 阅读 · 0 评论 -
【CodeForces - 574C】Bear and Poker(思维,剪枝,数学)
题干:Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-t...原创 2018-09-19 19:50:47 · 297 阅读 · 0 评论 -
*【CodeForces - 122D】Lucky Transformation(字符串问题,思维剪枝,优化,有坑,需注意的问题if的层次总结)
题干:Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky ...原创 2018-10-10 18:53:28 · 394 阅读 · 0 评论