UVALive
来源:互联网 发布:初学者视频剪辑软件 编辑:程序博客网 时间:2024/05/16 07:13
给n个面积的蛋糕,要求每个人最后只拿一个等面积的圆蛋糕,问最后每个人能拿到的最大的面积是多少?
所有蛋糕都是完整的圆以及 每个人拥有圆形蛋糕的 面积与他人一样
#include<cstdio>#include<iostream>#include<cmath>using namespace std;const int maxn=10000+10;const double PI=acos(-1);//注意包含头文件cmath int n,f;double a[maxn];bool ok(double area){int sum=0;for(int i=0;i<n;i++){sum+=floor(a[i]/area);if(sum>=f+1) return true;}return false;}int main(){int T;scanf("%d",&T);while(T--){double maxa=-1;int r;scanf("%d%d",&n,&f);for(int i=0;i<n;i++){scanf("%d",&r);a[i]=PI*r*r;maxa=max(maxa,a[i]);}double L=0,R=maxa;while(R-L>1e-5){double M=(L+R)/2;if(ok(M)) L=M;else R=M;}printf("%.3lf\n",L);}return 0;}
1 0
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- c++ STL的list用法总结
- request中的遍历,Cookie ,Session,Application--4.21号学习总结
- java
- 在32位操作系统gcc编译器环境下,关于字符对齐
- C++远航之封装篇——对象指针、this指针
- UVALive
- Ros平台下:从零开始学习SLAM(序)
- 探索推荐引擎内部的秘密系列
- maven学习-壹
- 可变参数列表源码的剖析
- (转)资产管理和财富管理的区别
- bzoj2738: 矩阵乘法
- 51单片机中控制PWM波
- python-requests(二)