参考: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. AWK学习总结(三) Records and Fields

    AWK 记录和域 The NR Variable % awk '{print NR, $0}' employees 1 Tom Jones 4424 5/12/66 543354 2 Mary Ada ...

  2. [Android6.0][RK3399] 双屏异显代码实现流程分析(一)【转】

    本文转载自:http://blog.csdn.net/dearsq/article/details/55049182 Platform: RK3399 OS: Android 6.0 Version: ...

  3. RK3288][Android6.0] 调试笔记 --- 关闭按键音后无法录音问题【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/70052413 Platform: ROCKCHIPOS: Android 6.0Kernel ...

  4. POJ 2260:Error Correction

    Error Correction Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6014   Accepted: 3886 ...

  5. go语言---map

    go语言---map https://blog.csdn.net/cyk2396/article/details/78890185 一.map的用法: type PersonDB struct { I ...

  6. MARK ZUCKERBERG, A letter to our daughter(转)

    A letter to our daughter   MARK ZUCKERBERG·WEDNESDAY, DECEMBER 2, 2015   Dear Max, Your mother and I ...

  7. 11.7NOIP模拟题

    /* 有循环节 */ #include<cstdio> #include<cstring> #include<iostream> #include<algor ...

  8. INT类型知多少

    前言: 整型是MySQL中最常用的字段类型之一,通常用于存储整数,其中int是整型中最常用的,对于int类型你是否真正了解呢?本文会带你熟悉int类型相关知识,也会介绍其他整型字段的使用. 1.整型分 ...

  9. PostgreSQL逻辑复制之pglogical篇

    PostgreSQL逻辑复制之slony篇 一.pglogical介绍 pglogical 是 PostgreSQL 的拓展模块, 为 PostgreSQL 数据库提供了逻辑流复制发布和订阅的功能. ...

  10. 清除WebSphere部署应用所对应的JSP缓存

    Web应用部署在WebSphere Application Server v8.5后程序一般放置在<AppServer>/profiles/<profile_name>/ins ...