【二分】
ACMerszl
一事精致,便能动人
展开
-
POJ2456-Aggressive cows
题目链接:点击打开链接DescriptionFarmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 <= xi <= 1,000...原创 2018-04-15 09:36:49 · 162 阅读 · 0 评论 -
POJ1064-Cable master
题目链接:点击打开链接DescriptionInhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest conte...原创 2018-04-16 16:28:46 · 123 阅读 · 0 评论 -
POJ2456 Aggressive cows
题目:http://poj.org/problem?id=2456思路:二分经典题目,二分答案,判断间隔mid是否能容纳所有的奶牛。不过二分坑点比较多例如查找值的时候,while里面写<=, 否则{1,3,5}查找不到5,返回值也是很迷的。这道题返回mid是错误的。可以从结束条件分析,结束条件:l > r, 前一个状态下的 l+1 了,所以最后返回 l-1(纯属个人理解)...原创 2018-08-03 09:29:55 · 285 阅读 · 0 评论