
二分
文章平均质量分 60
ComBoat
俺好菜呀o(╥﹏╥)o
展开
-
POJ 3663 Costume Party(二分)
DescriptionIt’s Halloween! Farmer John is taking the cows to a costume party, but unfortunately he only has one costume. The costume fits precisely two cows with a length of S (1 ≤ S ≤ 1,000,000). FJ has N cows (2 ≤ N ≤ 20,000) conveniently numbered 1…N;原创 2021-02-23 18:14:49 · 156 阅读 · 0 评论 -
CordForce 604B More Cowbell(贪心 二分)
descriptionKevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of corn. Before moving, he must pack his cowbells into k boxes of a fixed size. In order to keep his collection safe原创 2021-02-20 11:13:28 · 213 阅读 · 0 评论 -
二分查找
在一个有序的数组中查找某个数算法思路定义三个下标指针,right,mid,left。mid为left加right除以2,若mid对应的值等于目标值,则直接返回mid;若mid值大于目标值,则让right=mid-1;若mid值小于目标值,则让left=mid+1;直到mid值等于目标值,或left>right,退出循环。#include<iostream>#include<algorithm>using namespace std;int BinarySearch原创 2021-02-07 20:50:50 · 87 阅读 · 0 评论 -
OpenJudge 8211 派
描述我的生日要到了!根据习俗,我需要将一些派分给大家。我有N个不同口味、不同大小的派。有F个朋友会来参加我的派对,每个人会拿到一块派(必须一个派的一块,不能由几个派的小块拼成;可以是一整个派)。我的朋友们都特别小气,如果有人拿到更大的一块,就会开始抱怨。因此所有人拿到的派是同样大小的(但不需要是同样形状的),虽然这样有些派会被浪费,但总比搞砸整个派对好。当然,我也要给自己留一块,而这一块也要和其他人的同样大小。请问我们每个人拿到的派最大是多少?每个派都是一个高为1,半径不等的圆柱体。输入第一行包含原创 2021-02-09 09:40:15 · 184 阅读 · 0 评论 -
POJ 2456 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,000,000).His C (2 <= C <= N) cows don’t like this barn layout and b原创 2021-02-07 22:25:39 · 105 阅读 · 0 评论