POJ 1064 Cable master 一开始把 int C(double x) 里面写成了  int C(int x) ,莫名奇妙竟然过了样例,交了以后直接就wa. 后来发现又把二分查找的判断条件写错了,wa了n次,当 c(mid)<=k时,令ub=mid,这个判断是错的,因为要找到最大切割长度,当满足这个条件时,可能已经不是最大长度了,此时还继续缩小区间,自然就wa了,(从大到小递减,第一次满足这个条件的值,就是最大的值),正确的判断是当 c(mid)<k时,令ub=mid,这样循环1…
题目链接:http://poj.org/problem?id=1064 题意:有n条绳子,长度为Li,现在从这n条绳子中切割出K条相等的绳子,问切割出来的这k条绳子的最大长度为多少: 二分判断即可: 但是本题的精度让人恶心: #include<iostream> #include<algorithm> #include<string.h> #include<stdio.h> #include<math.h> using namespace std…
https://vjudge.net/problem/POJ-1064 二分就相当于不停地折半试. C++AC,G++WA不知为何,有人说C函数ans那里爆int了,改了之后也没什么用. #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<algorithm> #include<cmath> #include<map>…
Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26596   Accepted: 5673 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to…
Cable master Descriptions 输入2个数 N  K n条绳子    要分成大于等于k段 求每段最长多长呢?并且每段不能小于1cm 必须以厘米精度写入数字,小数点后正好是两位数.如果无法切割所请求的每个长度至少为1厘米的件数,则输出文件必须包含单个数字“0.00”(不带引号). 多组文件输入 Sample Input 4 11 8.02 7.43 4.57 5.39 Sample Output 2.00 题目链接 https://vjudge.net/problem/POJ-…
题目链接 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect computers for the contestan…
Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect computers for the contestants using a "star&…
Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21071   Accepted: 4542 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to…
题目链接: 传送门 Cable master Time Limit: 1000MS     Memory Limit: 65536K 题目描述 有N条绳子,它们长度分别为Li.如果从它们中切割出K条长度相同的绳子的话,这K条绳子每条最长能有多长?答案保留小数点后两位. 思路 二分搜索答案 #include<iostream> #include<cstdio> #include<cmath> #define EPS 1e-6 const int INF = 100000;…
给出n根绳子,求把它们分割成K条等长的绳子的最大长度是多少? 二分 用 for(int i=0; i<100; ++i) 取代   while(r-l>eps) 循环100次精度能达到1e-30,基本上能一般题目的精度要求. 而 浮点数二分区间的话easy产生精度缺失导致死循环. #include<cstdio> double L[10000 + 10]; int n, k; int ok(double x) { int cnt = 0; for(int i=0; i<n;…
题目:题目太长了! https://vjudge.net/problem/POJ-1064 题意分析:给了你N根长度为小数形式的棍子,再给出了你需要分的棍子的数量K,但要求你这K根棍子的长度必须是一样长的.需要你求解出满足题意的最长可能的棍子长度.根据二分找最大值的应用写即可. 需要注意的是: 1.注意题目给的范围是All cables are at least 1 meter and at most 100 kilometers in length: 2.在写满足条件的函数时,对于int强制转…
题目链接:传送门 题目大意: 给出n根长度为1-1e5的电线,想要从中切割出k段等长的部分(不可拼接),问这个k段等长的电线最长可以是多长(保留两位小数向下取整). 思路: 很裸的题意,二分答案即可. 但是如果使用double类型的二分会有浮点误差. 比如答案为2.50,二分的右区间r也为2.50时,则不管怎么二分,mid总是小于右区间的.也就是说mid最大只能取到2.50-eps/2 = 2.4999995,根据题意保留两位小数向下取整后的值就是2.49了. 因此对于这题的向下取整,在取整操作…
http://poj.org/problem?id=1064 题意:共有n段绳子,要求总共被分为k段.问在符合题意的前提下,每段长最大是多少? #include <iostream> #include <stdio.h> #include <string.h> #include <string> #include <vector> #include <algorithm> #include <map> #include &…
题目: 这题有点坑,G++过不了,C++能过. 条件:n个数据a[],分成k段,结果精度要求两位小数. 问题:每段最长为多少? 思路:因为精度要求为两位小数,我先把所有的长度a[]*100. 我们对答案二分搜索,把l设置为0,r设置为1000*10000*100+1(数据量*每个数据最大的大小*精度+1). 这样我们搜索的数就不用处理精度了,我们可以二分算出结果然后除以100. 代码: #include <iostream> #include <algorithm> #includ…
http://poj.org/problem?id=1064 题目大意: 有N条绳子,他们的长度分别为Li,如果从它们中切割出k条长度相同的绳子的话,这K条绳子每条能有多长? 思路: 二分,设答案为mid=(L+R)/2, 如果以mid划分可以分割出不小于K条绳子,那么解>=mid, 否则解小于mid PS: 最后的输出坑死了.要保留两位整数且不进位....T T #include<cstdio> #include<cmath> const int MAXN= 10000+1…
嗯... 题目链接:http://poj.org/problem?id=1064 其实这是一道很好想的二分答案的一道题... 二分的区间就是1~max_l,从1开始是因为所有小于1的都需要按0计算,没必要讨论了... 每次二分出来的答案看它能否把电缆切成大于等于k块,如果可以,我们不能保证它是最优的答案,所以要向更大的地方二分:如果现在都不可以,我们必须向更小的地方二分,才有可能可以. 这道题注意二分一般在整数中二分,所以我们先把它们都乘100,如果要求精度更高,则乘的数更大,然后再整数二分,最…
题意:给出n块木板,它们分别的高度,现在要把它们裁切成k块,问裁切成的最大的高度 二分答案,上限是这n块木板里面的最大值 然后每一个答案去判断一下是否满足能够裁切成k块 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include&l…
和杭电那一题一样,只不过G++交不能通过,C++能过 wa了好多好多好多次----------------------------------------- #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include<set&…
题目链接:http://poj.org/problem?id=1064 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to conn…
Cable master 求电缆的最大长度(二分法)   Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect com…
/* POJ1064 Cable master 时间限制: 1000MS 内存限制: 10000K 提交总数: 58217 接受: 12146 描述 Wonderland的居民已经决定举办地区性编程比赛.评委会自愿并承诺举办有史以来最诚实的比赛.决定使用“星形”拓扑结构为参赛者连接计算机 - 即将它们全部连接到单个中央集线器.为了组织一场真正诚实的比赛,评审委员会负责人决定将所有参赛选手均匀地放在距离该比赛中心的地方. 为了购买网线,评审委员会联系了当地的网络解决方案供应商,要求为他们出售具有相…
Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 35269   Accepted: 7513 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to…
poj 1064 Cable master 判断一个解是否可行 浮点数二分 题目链接: http://poj.org/problem?id=1064 思路: 二分答案,floor函数防止四舍五入 代码: #include <iostream> #include <stdio.h> #include <math.h> #include <algorithm> using namespace std; const int maxn = 10005; const…
Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 65358   Accepted: 13453 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to…
Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect computers for the contestants us…
地址 http://poj.org/problem?id=1064 题解 二分即可 其实 对于输入与精度计算不是很在行 老是被卡精度 后来学习了一个函数 floor 向负无穷取整 才能ac 代码如下 #include <iostream> #include <vector> #include <math.h> #include <algorithm> using namespace std; vector<double> v; int n, k;…
A - Cable master Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect computers for the contestan…
Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 29554   Accepted: 6247 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to…
Cable master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2473    Accepted Submission(s): 922 Problem Description Inhabitants of the Wonderland have decided to hold a regional programming con…
Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect computers for the contestants using a "star&…