Cable master POJ - 1064】的更多相关文章

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&…
缆绳大师 题目大意,把若干线段分成K份,求最大能分多长 二分法模型,C(x)就是题干的意思,在while那里做下文章就可以了,因为这个题目没有要求长度是整数,所以我们要不断二分才行,一般50-100次就可以了,精度足够了 最后要注意,这一题有四舍五入的陷阱,最好用floor处理一下 #include <iostream> #include <algorithm> #include <functional> #include <math.h> #define…
题目链接: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…
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…
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…
题目传送门 /* 题意:n条绳子问切割k条长度相等的最长长度 二分搜索:搜索长度,判断能否有k条长度相等的绳子 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; double w[MAXN]; int n, k; int check(double len…
题目链接: 传送门 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;…
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: 10000K Total Submissions: 37865   Accepted: 8051 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: 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…