随笔分类 -  基本算法-二分

摘要:题目描述 Farmer John建造了一个有N(2 include include include include include include include include include include include include include include include incl 阅读全文
posted @ 2018-07-25 09:04 Roni_i 阅读(303) 评论(0) 推荐(0) 编辑
摘要:题目描述 这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石。组委会已经选择好了两块岩石作为比赛起点和终点。在起点和终点之间,有 NN 块岩石(不含起点和终点的岩石)。在比赛过程中,选手们将从起点出发,每一步跳向相邻的岩石,直至到达终点。 为了提高比赛难度,组委会计划移走一些岩石,使得选手们 阅读全文
posted @ 2018-07-24 21:57 Roni_i 阅读(276) 评论(0) 推荐(0) 编辑
摘要:题目描述 陶陶是个贪玩的孩子,他在地上丢了A个瓶盖,为了简化问题,我们可以当作这A个瓶盖丢在一条直线上,现在他想从这些瓶盖里找出B个,使得距离最近的2个距离最大,他想知道,最大可以到多少呢? 输入输出格式 输入格式: 第一行,两个整数,A,B。(B const double eps = 1e 8; 阅读全文
posted @ 2018-07-24 18:05 Roni_i 阅读(307) 评论(0) 推荐(0) 编辑
摘要:题目描述 有N条绳子,它们的长度分别为Li。如果从它们中切割出K条长度相同的 绳子,这K条绳子每条最长能有多长?答案保留到小数点后2位。 输入输出格式 输入格式: 第一行两个整数N和K,接下来N行,描述了每条绳子的长度Li。 输出格式: 切割后每条绳子的最大长度。 输入输出样例 输入样例 1: 4 阅读全文
posted @ 2018-07-24 17:25 Roni_i 阅读(554) 评论(0) 推荐(1) 编辑
摘要:题目描述 话说KC和SH在福州的时候常常跑去85°C喝咖啡或者其他的一些什么东西。 这天,KC想要喝一杯咖啡,服务员告诉他,现在有n种调料,这杯咖啡只可以加入其中的m种(当然KC一定会加入m种,不会加入少于m种的调料),根据加入的调料不同,制成这杯咖啡要用的时间也不同,得到的咖啡的美味度也不同。 K 阅读全文
posted @ 2018-07-24 16:48 Roni_i 阅读(300) 评论(0) 推荐(0) 编辑
摘要:【代码】: include const double eps = 1e 8; const int maxn = 1e6+5; define inf 0x3f3f3f3f define ll long long using namespace std; int n,m; int a[maxn]; in 阅读全文
posted @ 2018-07-24 15:52 Roni_i 阅读(265) 评论(0) 推荐(0) 编辑
摘要:914 Yougth的最大化 内存限制:64MB 时间限制:1000ms 特判: No 通过数:3 提交数:4 难度:4 题目描述: Yougth现在有n个物品的重量和价值分别是Wi和Vi,你能帮他从中选出k个物品使得单位重量的价值最大吗? 输入描述: 有多组测试数据 每组测试数据第一行有两个数n和 阅读全文
posted @ 2018-07-24 14:15 Roni_i 阅读(336) 评论(0) 推荐(0) 编辑
摘要:Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of boxes, 阅读全文
posted @ 2018-07-24 13:53 Roni_i 阅读(284) 评论(0) 推荐(0) 编辑
摘要:Now,given the equation 8 x^4 + 7 x^3 + 2 x^2 + 3 x + 6 == Y,can you find its solution between 0 and 100; Now please try your lucky. Input The first li 阅读全文
posted @ 2018-07-24 09:40 Roni_i 阅读(216) 评论(0) 推荐(0) 编辑
摘要:Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers Ai, Bj, Ck, whic 阅读全文
posted @ 2018-07-24 09:00 Roni_i 阅读(211) 评论(0) 推荐(0) 编辑
摘要:You are given an array d1,d2,…,dn consisting of n integer numbers. Your task is to split this array into three parts (some of which may be empty) in s 阅读全文
posted @ 2018-07-22 16:12 Roni_i 阅读(289) 评论(0) 推荐(0) 编辑
摘要:``` #include using namespace std; const int N = 1e6,INF = 0x3f3f3f3f; int a[N]; int n,x; void fun(int n) { int left = 0, right = n-1; while(left x) { right--; } ... 阅读全文
posted @ 2018-07-02 12:42 Roni_i 阅读(353) 评论(0) 推荐(0) 编辑
摘要:【链接】: " CF978C " 【分析】:在前缀和数组种二分找到 =询问数的位置,根据位置就好操作了 【代码】: include using namespace std; const int INF = 0x3f3f3f3f; define ll long long define ms(a,b) 阅读全文
posted @ 2018-06-02 00:43 Roni_i 阅读(289) 评论(0) 推荐(0) 编辑
摘要:【https://www.jisuanke.com/contest/1228/74417】 阅读全文
posted @ 2018-05-12 20:25 Roni_i 阅读(287) 评论(0) 推荐(0) 编辑
摘要:【题意】: 题意就是说有n块石头,每块石头中间有一定的距离,一次可以跳过多个石头,但是不可以超过k步,求最大步的最小值 。 其实意思就是说,如果你每一步比较小,比如一块一块石头地过去,那么步数就太多了;但是如果你直接一步跳到最后,这样又太浪费体力了,而且不符合题意,而题意就是要你找到这么一个平衡点, 阅读全文
posted @ 2018-04-30 22:25 Roni_i 阅读(320) 评论(0) 推荐(0) 编辑
摘要:二分最化最值问题 大多数情况下用于求解满足某种条件下的最大(小)值。 答案单调性: 答案的单调性大多数情况下可以转化为一个函数,其单调性证明多种多样,如下: 移动石头的个数越多,答案越大(NOIP2015跳石头)。 前i天的条件一定比前 i + 1 天条件更容易(NOIP2012借教室)。 满足更少 阅读全文
posted @ 2018-04-30 14:30 Roni_i 阅读(158) 评论(0) 推荐(0) 编辑
摘要:二分最化最值问题 把一个包含n个正整数的序列划分成m个连续的子序列(每个正整数恰好属于一个序列). 设i个序列的各数之和为s(i).你的任务是让所有s(i)的最大值尽量小. 这个算法很有现实意义.给你一堆乱七八糟的东西分堆,分出来的东西都不超过一个固定的数值,这是需要技术含量的喔. 1.首先确定二分 阅读全文
posted @ 2018-04-30 14:20 Roni_i 阅读(345) 评论(0) 推荐(0) 编辑
摘要:``` 链接:https://www.nowcoder.com/acm/contest/84/F 来源:牛客网 题目描述 给定n个数,从中选出三个数,使得最大的那个减最小的那个的值小于等于d,问有多少种选法。 输入描述: 第一行两个整数n,d(1 c && a[j 1] using namespac 阅读全文
posted @ 2018-04-28 09:23 Roni_i 阅读(252) 评论(0) 推荐(0) 编辑
摘要:B. Powers of Two B. Powers of Two You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power o 阅读全文
posted @ 2018-04-18 18:17 Roni_i 阅读(306) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; #define ll long long #define maxn 100010 /* 已知一个序列A1.A2….An,给你一个整数K,找到满足所有Ai+Aj>=k的数对(i,j)的个数 */ int main 阅读全文
posted @ 2018-04-18 18:05 Roni_i 阅读(983) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示