Visit Counter
AmazingCounters.com

1、题目大意:给你n块蛋糕,分给m个人,每个人只能分其中一个蛋糕的某一部分,,。问每人最多分多少
2、分析:一个简单的二分题,,,被精度卡的wa了几次,就是二分这个分的个数,然后判断,判断,就是暴力的判断,
算出每块蛋糕能分几个人,,然后就没了
3、代码:

#include <cmath> 
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
#define LL long long
LL R[100000];
LL n, r;
bool right(LL st){
    LL orz = 0;
    for(int i = 1; i <= n; i ++){
        double s = R[i] * R[i] * 10000.0 * M_PI;
        orz += s / st;
    }
    if(orz >= r) return true;
    return false;
}
int main(){
    scanf("%lld%lld", &n, &r);
    r ++;
    for(int i = 1; i <= n; i ++){
        scanf("%lld", &R[i]);
    }
    LL ll = 0, rr = 10000000000009ll;
    while(ll < rr){
        LL mid = (ll + rr) / 2;
        if(mid == ll) mid ++;
        if(right(mid)) ll = mid;
        else rr = mid - 1;
    }
    double wt = ll / 10.0;
    LL yy = (LL)(wt + 0.5 + 0.00001);
    printf("%.3lf\n", yy / 1000.0);
    return 0;
}