题意:有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. Oracle 索引 简单介绍

    1 索引的创建语法: CREATE UNIUQE | BITMAP INDEX <schema>.<index_name>       ON <schema>.&l ...

  2. 安装protobuf可能遇到的问题

    下载protobuf-2.3.0:    http://protobuf.googlecode.com/files/protobuf-2.3.0.zip http://code.google.com/ ...

  3. Tika解析word文件

    Apache POI - HWPF and XWPF - Java API to Handle Microsoft Word Files http://poi.apache.org/document/ ...

  4. 数据仓库建模与ETL的实践技巧(转载)

    一.Data仓库的架构 Data仓库(Data Warehouse DW)是为了便于多维分析和多角度展现而将Data按特定的模式进行存储所建立起来的关系型Datcbase,它的Data基于OLTP源S ...

  5. HDU5363:Key Set

    Problem Description soda has a set S with n integers {1,2,-,n}. A set is called key set if the sum o ...

  6. codevs1032

    题目地址:http://codevs.cn/problem/1032/ 分析: 题目数据有错.这题过不了才正常. 我调了非常久可是就是有两个点过不去.于是我把数据下了下来,找到WA的第五个点和第七个点 ...

  7. arcgis for javascript 隐藏或显示底图

    arcgis for javascript展示地图的时候,有图层的概念,一层一层的,类似photoshop,在应用界面上控制图层的显隐,是极常见的功能. 但是,如果是控制底图的显示或隐藏呢,怎么搞? ...

  8. Mixtures of Gaussians and the EM algorithm

    http://cs229.stanford.edu/ http://cs229.stanford.edu/notes/cs229-notes7b.pdf

  9. !推荐:下载abap 源代码

    转自http://blog.sina.com.cn/s/blog_4d1570de0100pvhd.html *@------------------------------------------- ...

  10. POSTGRESQL主备部署模式

    一.预期目的 主数据库(Primary pg ,假定主机名为A,后文不再赘述)和备用数据库(Standby pg,假定主机名为B,后文不再赘述)之间的数据能够相互备份. 主数据库发生故障时备用数据库可 ...