LA 3635 派
题意:
f+1个人,来分 n 个圆形派,每个人只能从一个派中拿,也就是说,不能从两个里面去拼。
求每个人最大的面积。
分析:
二分。
二分能够得到的最大面积x,怎么判断是否可以分到呢? 把每一个派分成 x,有多少份>=f+1,即可;
#include <bits/stdc++.h> using namespace std; const int maxn = + ;
const double PI = acos(-1.0); int n,f;
double A[maxn]; bool ok(double x) {
int sum = ;
for(int i=;i<n;i++) {
sum +=(A[i]/x);
}
if(sum>=f+)
return true;
return false;
} int main()
{
int t;
scanf("%d",&t);
while(t--) {
scanf("%d%d",&n,&f);
double l=;
double r=-;
for(int i=;i<n;i++) {
int x;
scanf("%d",&x);
A[i] = PI*x*x;
r=max(r,A[i]);
} while(r-l>1e-) {
double M = (l+r)/;
if(ok(M)) l = M;
else r = M;
}
printf("%.4lf\n",l);
}
return ;
}
LA 3635 派的更多相关文章
- LA 3635 Pie 派 NWERC 2006
有 f + 1 个人来分 n 个圆形派,每个人得到的必须是一整块派,而不是几块拼在一起,并且面积要相同.求每个人最多能得到多大面积的派(不必是圆形). 这题很好做,使用二分法就OK. 首先在读取所有派 ...
- Java实现派(Pie, NWERC 2006, LA 3635)
题目 有F+1个人来分N个圆形派,每个人得到的必须是一整块派,而不是几块拼在一起,且面积要相同.求每个人最多能得到多大面积的派(不必是圆形). 输入的第一行为数据组数T.每组数据的第一行为两个整数N和 ...
- Uva 派 (Pie,NWERC 2006,LA 3635)
依然是一道二分查找 #include<iostream> #include<cstdio> #include<cmath> using namespace std; ...
- UVA 12097 LA 3635 Pie(二分法)
Pie My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a numbe ...
- LA 3635 Pie
题意:给出n个圆,分给n+1个人,求每个人最多能够得到多大面积的圆 二分每个人得到的圆的面积 #include<iostream> #include<cstdio> #incl ...
- 【二分答案】【POJ3122】【Northwestern Europe 2006】Pie
Pie Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10629 Accepted: 3744 Special Ju ...
- OI 刷题记录——每周更新
每周日更新 2016.05.29 UVa中国麻将(Chinese Mahjong,Uva 11210) UVa新汉诺塔问题(A Different Task,Uva 10795) NOIP2012同余 ...
- Meeting-in-the-Middle (LA 2965)
Meeting-in-the-Middle,又称“中途相遇法”.准确地说,它只是一种策略. 顺便说一下,这个算法真的很冷门! 结合这道题来讨论一下吧:LA 2965.ε(┬┬﹏┬┬)3 因为博主的英文 ...
- leggere la nostra recensione del primo e del secondo
La terra di mezzo in trail running sembra essere distorto leggermente massima di recente, e gli aggi ...
随机推荐
- linux安装php7
之前一直对linux研究的比较少,终于下定决心好好把linux玩一下 首先~我是安装了vm虚拟机,然后使用的是centos7的版本.因为vm不好复制粘贴,故使用了xshell连接了我的linux进行操 ...
- java——哈希表 HashTable
在一个类中重写hashCode()和equals() package Date_pacage.hash; public class Student { private int grade; priva ...
- appium连接夜神模拟器方法总结
使用appium连接模拟器前提条件:appium环境已经搭建完毕,搭建步骤请参考我的博客:appium手机自动化环境搭建 1.下载并安装夜神模拟器:https://www.yeshen.com/ 2. ...
- 这是通过 Open Live Writer(是个博客编辑器) 发布的
Open Live Writer 是开源的win10上的博客编辑器
- Oracle基础篇--03DML语言
1.数据准备: --创建表格的 create table dept as select * from scott.dept; create table emp as select * from sco ...
- speex编译
首先去官网 https://www.speex.org/downloads/ 下载解压 将include.libspeex文件夹复制到自己新建工程的jni目录下 speex有关的类 package c ...
- Linux 系统 文件锁 fcntl函数详解
#include <unistd.h> #include <fcntl.h> int fcntl(int fd, int cmd); int fcntl(int fd, int ...
- F. Cooking Time 贪心
http://codeforces.com/gym/101498/problem/F 对于知道使用情况的置换算法,最优解是找一个最后需要使用的物品替换掉 也就是,如果一个物品后面已经不需要用到,就要拿 ...
- 换晶振导致stm32串口数据飞码的解决办法
一般来说,stm32f107都是用标配的晶振,比如8MHz. 但是,如果用别的晶振,比如13.56M的晶振,那串口接收还正常吗? 根据试验结果,很可能会飞码.比如说用串口助手发送的是0x35,但是在串 ...
- HDU 5375——Gray code——————【dp||讨论】
Gray code Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...