http://codeforces.com/problemset/problem/424/B

给n,s

给n个城市,以及里面人口

坐标中心0,0 有s人,

现在扩宽以0,0为中心,半径为r 圈一个圈,使得圈内人口大于等于1e6,求最小的r

直接二分R,每次判断够不够1e6

#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;const double pi=acos(-1.0);
double eps=0.000001;
__int64 min(__int64 a,__int64 b)
{return a<b?a:b;}
__int64 max(__int64 a,__int64 b)
{return a>b?a:b;} __int64 n;
struct node
{__int64 x,y,z;double dis;
};
node tm[1005];
__int64 need=0;
__int64 bin(double x)
{__int64 sum=0;__int64 i;for (i=1;i<=n;i++){if (tm[i].dis<=x)sum+=tm[i].z;elsebreak;if (sum>=need) return 1;}return 0;
}
bool cmp(node a,node b)
{return a.dis<b.dis;}
int main()
{__int64 i,j;__int64 s;scanf("%I64d%I64d",&n,&s);for (i=1;i<=n;i++){scanf("%I64d%I64d%I64d",&tm[i].x,&tm[i].y ,&tm[i].z);tm[i].dis=tm[i].x*tm[i].x+tm[i].y*tm[i].y;}sort(tm+1,tm+1+n,cmp);need=1000000-s;double l=0;double r=1e10;double ans=-1;while(fabs(r-l)>eps){double mid=(l+r)/2;if (bin(mid))r=mid,ans=mid;elsel=mid;}if (ans==-1) printf("-1\n");elseprintf("%.6lf\n",sqrt(ans));return 0;}

codeforces#242B-Megacity-二分相关推荐

  1. CodeForces - 1550E Stringforces(二分+状压dp)

    题目链接:点击查看 题目大意:给出一个长度为 nnn 的字符串,只包含前 kkk 个小写字母以及通配符 ???,现在可以将通配符替换成任意的前 kkk 个字母中的一个.设 f[i]f[i]f[i] 为 ...

  2. CodeForces 359D (数论+二分+ST算法)

    题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=47319 题目大意:给定一个序列,要求确定一个子序列,①使得该子序 ...

  3. CodeForces - 1059D(二分+误差)

    链接:CodeForces - 1059D 题意:给出笛卡尔坐标系上 n 个点,求与 x 轴相切且覆盖了所有给出点的圆的最小半径. 题解:二分半径即可.判断:假设当前二分到的半径是 R ,因为要和 x ...

  4. Anton and Fairy Tale CodeForces - 785C(二分+思维)

    Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right ...

  5. Shovels and Swords CodeForces - 1366A(二分)

    Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft to ...

  6. K-th Beautiful String CodeForces - 1328B(二分+数学)

    For the given integer n (n>2) let's write down all the strings of length n which contain n−2 lett ...

  7. Frog Jumps CodeForces - 1324C(二分)

    There is a frog staying to the left of the string s=s1s2-sn consisting of n characters (to be more p ...

  8. CF思维联系– CodeForces - 991C Candies(二分)

    ACM思维题训练集合 After passing a test, Vasya got himself a box of n candies. He decided to eat an equal am ...

  9. codeforces 732/D 二分

    给出考试时间和考试需要准备的时间,问最早考完所有科目的时间 二分答案 NlogN 二分抄神犇的写法 感觉挺舒服的嘻嘻嘻 1 #include<bits/stdc++.h> 2 using ...

  10. Educational Codeforces Round 53C(二分,思维|构造)

    #include<bits/stdc++.h> using namespace std; const int N=1e6+6; int x[N],y[N]; int sx,sy,n; ch ...

最新文章

  1. 64岁Python之父:退休生活太无聊,我要加入微软,将开源进行到底
  2. 成本并非企业奔向云计算的唯一原因
  3. javascript 窗口加载事件相关问题
  4. BootStrap网格布局
  5. java课程总结_java课程总结报告.doc
  6. mme设备内部错误_华为拟安装“俄版安卓”;百度回应内部贪腐;Android Studio 3.5 RC2 发布 | 极客头条...
  7. Android Studio实现音乐播放器2.0
  8. 同义词转换不再有效_中考英语丨初中英语句型转换大全
  9. 【FPGA - 基础知识(零)】FPGA芯片资源介绍
  10. 第五次项目《超市会员管理Plus》
  11. 卷积自编码器(Convolutional Autoencoder)的一个实验
  12. 基于selenium的码市外包信息爬虫
  13. FPGA有哪些优质的带源码的IP开源网站?
  14. Qt(C++)入门学习
  15. LeetCode第127题—单词接龙—Python实现
  16. 从 Godaddy 转移域名到 Namesilo
  17. 面试进行曲之技术面试(项目经验)
  18. 2021-08-15关于水卡数据算法,求助大神
  19. jdk的环境变量,javac不是内部命令,也不是可运行的程序”的解决
  20. AI大模型知识点大梳理

热门文章

  1. 《阿里工程师的自我修养》笔记
  2. 分子生物学实验计算机,BioSun2.0:一个综合性的辅助分子生物学实验设计软件
  3. 第二十三章 案例分析
  4. 相关性分析——皮尔逊
  5. 2021年中国超融合十大趋势
  6. [专栏精选]Unity动画系统的IK详解
  7. chrome优秀插件推荐
  8. 整理动力节点王鹤老师ssm整合步骤
  9. 霓虹灯颜色渐变flash素材
  10. 2大学英语四级关于计算机的图表作文,大学英语四级图表作文真题写作模板