参考:https://blog.csdn.net/KuHuaiShuXia/article/details/78408194

题意:

描述了吃鸡刷圈的问题,给出楼的坐标点,和两次刷圈的半径R和r,现在寻找最安全的地方

思路:

判定安全方法:每个点以r为半径画圆,与以原点为圆心,半径为R的圆的重合部分的大小为比较基准

那么问题又转化为与原点的距离

如果R>2r,那么以大圈圆心为圆心的R-2r范围内的建筑的安全概率是相等的。

反之,以大圈圆心为圆心的2*r-R范围内的建筑的安全概率是相等的。

我们只需要判断是否是一致概率,然后添加到结果集合,使用vector

代码:

#include<iostream>
#include<cstdio>
#include<vector>
using namespace std; int main() {
int t, n, R, r;
scanf("%d", &t);
while(t--) {
vector<int> vi;
int x, y, d, inf = 0xf3f3f3f, tmp;
scanf("%d %d %d", &n, &R, &r);
if(R >= 2*r) d = R - 2*r;
else d = 2*r - R;
for(int i = 1; i <= n; i++) {
scanf("%d %d", &x, &y);
if(x*x+y*y <= d*d) tmp = 0;
else tmp = x*x+y*y;
if(tmp < inf) {
inf = tmp;//更新最小
vi.clear();
}
if(tmp == inf) vi.push_back(i);
}
printf("%d\n", vi.size());
for(int i = 0; i < vi.size(); i++) {
printf("%d%c", vi[i],i==vi.size()-1?'\n':' ');
} }
return 0;
}

ZOJ - 3993 - Safest Buildings (数学)的更多相关文章

  1. ZOJ 3993 - Safest Buildings - [数学题]

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3993 题意: 给出n幢建筑,每个都以一个点表示,给出点坐标. 有 ...

  2. 2017 CCPC秦皇岛 M题 Safest Buildings

    PUBG is a multiplayer online battle royale video game. In the game, up to one hundred players parach ...

  3. HDU 5301 Buildings 数学

    Buildings 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5301 Description Your current task is to m ...

  4. ZOJ 1494 Climbing Worm 数学水题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=494 题目大意: 一只蜗牛要从爬上n英寸高的地方,他速度为u每分钟,他爬完u需要 ...

  5. zoj.3868.GCD Expectation(数学推导>>容斥原理)

    GCD Expectation Time Limit: 4 Seconds                                     Memory Limit: 262144 KB    ...

  6. ZOJ 3903 Ant(数学,推公示+乘法逆元)

    Ant Time Limit: 1 Second      Memory Limit: 32768 KB There is an ant named Alice. Alice likes going ...

  7. ZOJ 3702 Gibonacci number(数学推导)

    公式推导题,G(0) = 1,G(1) = t,给出一个 i 和 G(i),要求求出G(j)的值: G(0) = 0*t + 1 G(1) = 1*t + 0; 观察t的系数和常数值可以知道二者都遵循 ...

  8. zoj 1526 Big Number 数学

    Big Number Time Limit: 10 Seconds      Memory Limit: 32768 KB In many applications very large intege ...

  9. 2017CCPC秦皇岛 M题Safest Buildings&&ZOJ3993【复杂模拟】

    题意: 给出两个半径R,r,R表示第一次的大圈半径,r表示第二次的小圈半径.第一次大圈的圆心位于(0,0),第二次小圈的圆心未知,但在大圈内,给你一个n,然后给出n个屋子的位置,问这些屋子中,第二次在 ...

随机推荐

  1. Git经常使用命令总结

    Git是一款开源的分布式版本号控制系统,由Linux之父Torvalds用C语言开发. "the stupid content tracker",Git自诩为stupid,却是一个 ...

  2. 同一个站点下,兼容不同版本的JQuery

    https://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same-page Y ...

  3. socket listen backlog

    http://stackoverflow.com/questions/4253454/question-about-listening-and-backlog-for-sockets The list ...

  4. 并不对劲的spoj1811

    题意是求两个字符串的lcs,两个串都只包含小写字母. 本题既可以用后缀自动机,又可以用后缀数组. 对于后缀自动机,就是一道模板题,直接对于一个字符串建后缀自动机再用另一个串查询就行. 对于后缀数组,其 ...

  5. bzoj1875 [SDOI2009]HH去散步——矩阵快速幂

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1875 有个限制是不能走回头路,比较麻烦: 所以把矩阵中的元素设成边的经过次数,单向边之间就好 ...

  6. easyui-filebox 文件上传

    参考文章:http://blog.csdn.net/fsdad/article/details/73200618 easyui论坛:http://www.jeasyui.com/forum/index ...

  7. Unity ScriptObject

    http://godstamps.blogspot.com/2012/02/unity-3d-scriptableobject-assetbundle.html http://ivanozanchet ...

  8. set && muliset

    #include <set> #include <iostream> #include <cstdio> #include <cctype> using ...

  9. [LOJ#10132]异象石

    Description Adera 是 Microsoft 应用商店中的一款解谜游戏. 异象石是进入 Adera 中异时空的引导物,在 Adera 的异时空中有一张地图.这张地图上 有 N 个点,有 ...

  10. 题解报告:hdu 1015 Safecracker

    Problem Description === Op tech briefing, 2002/11/02 06:42 CST ===  "The item is locked in a Kl ...