题意:有f+1个人来分n个圆形派,每个人得到的必须是一个整块,并且是面积一样,问你面积是多少。

析:二分这个面积即可,小了就多余了,多了就不够分,很简单就能判断。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#define debug() puts("++++");
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e4 + 5;
const int mod = 2000;
const int dr[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[maxn]; bool judge(double mid){
int ans = 0;
for(int i = 0; i < n; ++i)
ans += (int)floor(PI * a[i] * a[i] / mid);
return ans >= m;
} double solve(){
double l = 0, r = PI * 10000.0* 10000.0;
while(fabs(r - l) > 1e-5){
double mid = (l + r) / 2.0;
if(judge(mid)) l = mid;
else r = mid;
}
return l;
} int main(){
int T; cin >> T;
while(T--){
scanf("%d %d", &n, &m);
++m;
for(int i = 0; i < n; ++i) scanf("%d", a+i);
printf("%.4f\n", solve());
}
return 0;
}

UVaLive 3635 Pie (二分)的更多相关文章

  1. UVALive 3635 Pie 切糕大师 二分

    题意:为每个小伙伴切糕,要求每个小盆友(包括你自己)分得的pie一样大,但是每个人只能分得一份pie,不能拿两份凑一起的. 做法:二分查找切糕的大小,然后看看分出来的个数有没有大于小盆友们的个数,它又 ...

  2. uvalive 3635 Pie

    https://vjudge.net/problem/UVALive-3635 题意: 有F+1个人要分n个蛋糕,他们得到的蛋糕的面积必须是一样的,但是每个蛋糕必须是整块的蛋糕,而不是有多块蛋糕拼成的 ...

  3. UVALive 3635 Pie(二分法)

    简单的二分法应用,循环1000次精度就满足要求了. #include<iostream> #include<cstdio> #include<cstdlib> #i ...

  4. 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 ...

  5. HDU 1969 Pie(二分查找)

    Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no ...

  6. HDU 1969 Pie(二分,注意精度)

    Pie Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  7. 【POJ 3122】 Pie (二分+贪心)

    id=3122">[POJ 3122] Pie 分f个派给n+1(n个朋友和自己)个人 要求每一个人分相同面积 但不能分到超过一个派 即最多把一整个派给某个人 问能平均分的最大面积 二 ...

  8. Pie(二分)

    http://poj.org/problem?id=3122 题意:将n个圆柱体的不同口味的pie分给m个人,要求每个人分得的pie必须体积相同,且来自于一块pie(即:只分得一种口味的pie),求最 ...

  9. UVALive 3635 分派

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

随机推荐

  1. ruby on rails模拟HTTP请求错误发生:end of file reached

    在文章 Ruby On Rails中REST API使用演示样例--基于云平台+云服务打造自己的在线翻译工具 中,利用ruby的Net::HTTP发起http请求訪问IBM Bluemix上的sour ...

  2. kubernetes高级之创建只读文件系统以及只读asp.net core容器

    系列目录 使用docker创建只读文件系统 容器化部署对应用的运维带来了极大的方便,同时也带来一些新的安全问题需要考虑.比如黑客入侵到容器内,对容器内的系统级别或者应用级别文件进行修改,会造成难以估量 ...

  3. 获取当前外网IP地址

    <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script><script>cons ...

  4. 如何将mysql的路径加入环境变量

    1.打开终端,输入: cd ~ 会进入~文件夹 2.然后输入:touch .bash_profile 回车执行后, 2.再输入:open -e .bash_profile 会在TextEdit中打开这 ...

  5. PythonCookBook笔记——迭代器与生成器

    迭代器与生成器 迭代是Python最强大的功能之一,虽然看起来迭代只是处理序列中元素的一种方法,但不仅仅如此. 手动遍历迭代器 想遍历但不想使用for循环. 使用next()方法并在代码中捕获Stop ...

  6. JQGrid总记录数和查询消耗时间不显示

    其他做的几个页面都显示,只有一个不显示....百度发现, viewrecords选项未配置,应该设置为ture才可以.

  7. UIAlertController Changes in iOS 8

    本文转载至 http://www.th7.cn/Program/IOS/201409/276000.shtml   As part of the theme of iOS 8 to make inte ...

  8. php 静态成员(static)抽象类(abstract)和接口(interface)

    首先看一下静态成员(static)和普通成员(public; protect; private)的区别: 静态成员是属于类的,普通成员是属于对象的: 例如: <?php header(" ...

  9. JQuery 如何获取select选中的值

    一.html代码 <select id="ddl"> <option value="100" emoney="12" &g ...

  10. Embed image in a <button> element 微信小程序 客服按钮

    html - Embed image in a <button> element - Stack Overflow https://stackoverflow.com/questions/ ...