派 二分水题

思路:就是二分派的体积,但是要处理一下高精度。

复制代码
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define IP acos(-1.0)
const int maxn = 1e4 + 10;
#define ll long long
#define max(a, b) (a)>(b)?(a):(b)
int t, n, f;
ll a[maxn];
ll r, maxx;
bool ok(ll x){
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        ans += a[i] / x;
        if (f + 1 <= ans)return 1;
    }
    return 0;
}

int main(){
    scanf("%d", &t);
    while (t--){
        maxx = 0;
        scanf("%d%d", &n, &f);
        for (int i = 0; i < n; ++i)
        {
            scanf("%lld", &r);    a[i] = IP*r*r * 10000;    maxx = max(maxx, IP*r*r*10000);
        }
        ll L = 0, R = maxx;
        while (R  >  L+1){
    //        cout << L << " " << R << endl;
            ll mid = (R + L) / 2.0;
            if (ok(mid))L = mid;  else R = mid;
        }
        printf("%.4lf\n", R / 10000.0);
    }
}
复制代码

 

作者:ALINGMAOMAO

出处:https://www.cnblogs.com/ALINGMAOMAO/p/10765518.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

posted @   青山新雨  阅读(187)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
more_horiz
keyboard_arrow_up light_mode palette
选择主题
点击右上角即可分享
微信分享提示