LA3635 - Pie

原创 2015年07月09日 21:33:42

My birthday is coming up and traditionally I'm
serving pie. Not just one pie, no, I have a number
N of them, of various tastes and of various sizes. F
of my friends are coming to my party and each of
them gets a piece of pie. This should be one piece
of one pie, not several small pieces since that looks
messy. This piece can be one whole pie though.
My friends are very annoying and if one of them
gets a bigger piece than the others, they start com-
plaining. Therefore all of them should get equally
sized (but not necessarily equally shaped) pieces,
even if this leads to some pie getting spoiled (which
is better than spoiling the party). Of course, I want
a piece of pie for myself too, and that piece should also be of the same size.
What is the largest possible piece size all of us can get? All the pies are cylindrical in shape and
they all have the same height 1, but the radii of the pies can be different.
One line with a positive integer: the number of test cases. Then for each test case:
 One line with two integers N and F with 1  N, F  10000: the number of pies and the number
of friends.
 One line with N integers ri with 1  ri  10000: the radii of the pies.
For each test case, output one line with the largest possible volume V such that me and my friends can
all get a pie piece of size V . The answer should be given as a oating point number with an absolute
error of at most 10

#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
#define PI acos(-1)
const int MAXN = 10010;
double S[MAXN];
int N, F;
bool check(double mid)
    int sum = 0;
    for(int i=0; i<N; i++)
        sum += floor(S[i]/mid);
    return sum>=F+1;
int main()
    int t, r;

        for(int i=0; i<N; i++)
            S[i] = r*r*PI;
        double min1 = 0, max1 = 1e14, mid;
            mid = (max1+min1)/2;
                min1 = mid;
                max1 = mid;
    return 0;




派(Pie,NWERC 2006,LA 3635)

派(Pie,NWERC 2006,LA 3635)

LA 3635 - Pie 【二分】

Regionals 2006 >> Europe - Northwestern 3635 - PieTime limit: 3.000 seconds My birthday is coming ...

UVALive - 3635 - Pie(二分)

题意:有F + 1(1 因为答案是小数类型的,并且N高达10000,故不可暴力枚举。 可以二分枚举最大面积,然后检查是否切出来派的总个数大于等于F + 1。 (判相等时不可直接判相等,...

UVALive - 3635 Pie(二分答案查找)

点击打开题目链接 Time limit: 1 second My birthday is coming up and traditionally I'm serving pie. Not ju...

UVALive 3635 Pie 【二分】

Pie Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

hdu3635 Dragon Balls--并查集

原题链接: 一:原题内容 Problem Description Five hund...
  • LaoJiu_
  • LaoJiu_
  • 2016年04月10日 11:19
  • 278

POJ 3635 Full Tank? 最短路DP

给出一个图(1≤n≤1000,0≤m≤100001\leq n\leq 1000,0\leq m\leq 10000),每个点有加油站费用cic_i,对于每个询问,油箱容积cc的车从ss到ee的最小费...

HDU 3635 Dragon Balls

Problem Description Five hundred years later, the number of dragon balls will increase unexpectedly...

poj 3635 (最短路,广搜,邻接表,dp)

题意 : n个城市,每个城市的油价不同,m条连通这些城市之间的路,提供油桶的容量,要你求出由城市s出发到城市e的最小费用,其中刚开始时油桶为空,一单位的油可以走以单位的长度。 看...

HDU 3635 Dragon Balls 并查集水题 模拟

题意:n个龙珠,编号为1...n,分别在编号1....n的城市中。有两种操作,T A B,把A所在的城市的龙珠全部放到B所在的城市里;Q A,查询龙珠A所在的城市,以及城市现在有几个球,以及A被转移了...
  • hcbbt
  • hcbbt
  • 2013年12月06日 14:42
  • 1641
您举报文章:LA3635 - Pie