HDU 1969 Pie
二分答案+验证(这题精度卡的比较死)
- #include<stdio.h>
- #include<math.h>
- #define eps 1e-7
- const int ff = ;
- double a[ff];
- double pi = acos(-1.0);
- int main()
- {
- int sb;
- scanf("%d", &sb);
- while (sb--)
- {
- int m, n;
- scanf("%d%d", &m, &n);
- int i, j;
- double maxn = ;
- for (i = ; i <= m; i++)
- {
- scanf("%lf", &a[i]);
- a[i] = a[i] * a[i] * pi;
- if (a[i] > maxn) maxn = a[i];
- }
- double minn = ;
- double midn = (minn + maxn) / 2.0;
- while ()
- {
- if (maxn - minn < eps)
- {
- printf("%.4lf\n", midn);
- break;
- }
- else
- {
- int sum = , flag;
- for (i = ; i <= m; i++) sum += (int)((1.0*a[i] / midn));
- if (sum >= n+) flag = ;
- else flag = ;
- if (flag) minn = midn, midn = (minn + maxn) / 2.0;
- else maxn = midn, midn = (minn + maxn) / 2.0;
- }
- }
- }
- return ;
- }
HDU 1969 Pie的更多相关文章
- hdu 1969 Pie(二分查找)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1969 Pie Time Limit: 5000/1000 MS (Java/Others) Me ...
- HDU 1969 Pie(二分法)
My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N ...
- HDU 1969 Pie(二分查找)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- HDU 1969 Pie(二分搜索)
题目链接 Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pi ...
- HDU 1969 Pie(二分,注意精度)
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- hdu 1969 Pie (二分法)
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- HDU 1969 Pie【二分】
[分析] “虽然不是求什么最大的最小值(或者反过来)什么的……但还是可以用二分的,因为之前就做过一道小数型二分题(下面等会讲) 考虑二分面积,下界L=0,上界R=∑ni=1nπ∗ri2.对于一个中值x ...
- 题解报告:hdu 1969 Pie(二分)
Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...
- hdu 1969 pie 卡精度的二分
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
随机推荐
- leaflet地图库
an open-source JavaScript libraryfor mobile-friendly interactive maps Overview Tutorials Docs Downlo ...
- 集成shareSDK的微信、QQ API导致cocoaPods找不到类symbol问题的解决方法
因为shareSDK的微信和QQ API都只支持32位的,而cocoaPods默认要支持64位的,所以如果在工程中导入这两个API会出问题. 解决方法我就不转载啦,原文在这里: http://blog ...
- ORACLE ORDER BY用法总结
order by后面的形式却比较新颖(对于我来说哦),以前从来没看过这种用法,就想记下来,正好总结一下ORDER BY的知识. 1.ORDER BY 中关于NULL的处理 缺省处理,Oracle在Or ...
- 私有云Rabbitmq 集群部署
默认openstack使用rabbitmq做信息队列,如果想要是云高可用,那么需要对每个涉及的组件都进行高可用配置,本文介绍如何使用rabbitmq 做高可用 高可用方法 通过 Erlang 的分布式 ...
- APICloud界面间跳转
UZModule提供属性controller,可通过该控制器对目标控制器进行push或者present操作. // push[self.viewController.navigationControl ...
- Weex-进阶笔记一
p.p1 { margin: 0.0px 0.0px 2.0px 0.0px; font: 14.0px Helvetica; color: #454545 } p.p2 { margin: 0.0p ...
- Webstrom 常用操作记录
WebStorm 编译 es6 与 scss 的教程: http://blog.jetbrains.com/webstorm/2015/05/ecmascript-6-in-webstorm-tran ...
- 【.NET】转载:使用FileStream批量上传文件。
先看效果图: 代码(没什么难度的一个案例,进度条为第三方控件ProgressODoom.dll,自己去网上下.) using System; using System.Collections.Gene ...
- AUC计算方法总结
一.roc曲线 1.roc曲线:接收者操作特征(receiveroperating characteristic),roc曲线上每个点反映着对同一信号刺激的感受性. 横轴:负正类率(false pos ...
- 【定位:PDF文件定位关键字所在坐标和页码】
iText简介: iText是著名的开放源码的站点sourceforge一个项目,是用于生成PDF文档的一个java类库.通过iText不仅可以生成PDF或rtf的文档,而且可以将XML.Html文件 ...