二分搜索 HDOJ 2289 Cup】的更多相关文章

题目传送门 /* 二分搜索:枚举高度,计算体积与给出的比较. */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; ; const double PI = acos (-1.0); double r, R, H, V; double x; double ca…
Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know the volume of the water in the cup, can you tell us it height? The radius of the cup's top and bottom circle is known, the cup's height is also kno…
二分.另外,圆台体积为v = PI*(r*r+r*R+R*R)*H/3.注意精度. #include <cstdio> #include <cmath> #define exp 1e-9 const double PI = acos(-1.0); int main() { int t; double r, R, H, v, lf, rt, mid, r0, nv; scanf("%d", &t); while (t--) { scanf("%l…
Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8942    Accepted Submission(s): 2744 Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know th…
题目传送门 /* 二分搜索:式子两边取对数,将x提出来,那么另一边就是一个常数了,函数是:lnx/x.二分搜索x,注意要两次 */ #include <cstdio> #include <algorithm> #include <cmath> using namespace std; const double e = exp (1.0); double cal(double x) { return log (x) / x; } int main(void) { //HD…
Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6684    Accepted Submission(s): 2062 Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know th…
Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7077    Accepted Submission(s): 2177 Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know th…
http://acm.hdu.edu.cn/showproblem.php?pid=2289 二分法解题. 这个题很恶心...一开始测试样例都不能过,这个π一开始取3.1415926结果是99.999026,改为3.1414927,结果是99.999023..我就发现这个π对结果影响很大,这个题对π的精度要求也比较高...然后我的π就改为3.1415926536... 一开始判断跳出二分的条件是结果差值小于0.000000001,发现超时,改为0.01后还是超时...无语了...然后仔细想想,题…
这道题目.运营商做数学题?算上两个子主题做?顶多算一个水主要议题... 首先,没有实际的二分法,但是,我们发现了一个新的解决方案,以取代二分法. 若果按照i从0,每次添加0.00000001我一直枚举h如果,绝对逼暂停.枚举太大 然而,它可以分为两个步骤: #include<cstdio> #include<cmath> #define pai acos(-1.0) double r1,r2,h,v; double get_v(double temp) { double rr=r1…
<题目链接> 题目大意: 一个圆台型的杯子,它的上底半径和下底半径已经给出,并且给出它的高度,问你,体积为V的水倒入这个杯子中,高度为多少. 解题分析: 就是简单的二分答案,二分枚举杯中水的高度,然后根据几何计算出该高度下,水的上半径,然后计算出该高度下水的体积,在与实际水的体积进行比较,从而确定最终的答案. #include <cstdio> #include <cstring> #include <cmath> const double PI=acos(…