Codeforces Round #430 B. Gleb And Pizza
Gleb ordered pizza home. When the courier delivered the pizza, he was very upset, because several pieces of sausage lay on the crust, and he does not really like the crust.
The pizza is a circle of radius r and center at the origin. Pizza consists of the main part — circle of radius r - d with center at the origin, and crust around the main part of the width d. Pieces of sausage are also circles. The radius of the i -th piece of the sausage is ri, and the center is given as a pair (xi, yi).
Gleb asks you to help determine the number of pieces of sausage caught on the crust. A piece of sausage got on the crust, if it completely lies on the crust.
Input
First string contains two integer numbers r and d (0 ≤ d < r ≤ 500) — the radius of pizza and the width of crust.
Next line contains one integer number n — the number of pieces of sausage (1 ≤ n ≤ 105).
Each of next n lines contains three integer numbers xi, yi and ri ( - 500 ≤ xi, yi ≤ 500, 0 ≤ ri ≤ 500), where xi and yi are coordinates of the center of i-th peace of sausage, ri — radius of i-th peace of sausage.
Output
Output the number of pieces of sausage that lay on the crust.
题目大意:一个分两层的大圆,给出一些小圆,求完全在大圆外层的小圆个数
题解报告:简单模拟,直接\(O(n)\)扫一边即可
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define RG register
#define il inline
#define iter iterator
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std;
const int N=1e5+5;
int x[N],y[N],r[N];int r1,d,n;
int js(int i){
return x[i]*x[i]+y[i]*y[i];
}
bool check(int i){
int dis=js(i);
int t1=(r1-r[i])*(r1-r[i]),t2=(r[i]+r1-d)*(r[i]+r1-d);
if(dis>=t2 && dis<=t1)return true;
return false;
}
void work()
{
scanf("%d%d%d",&r1,&d,&n);
for(int i=1;i<=n;i++){
scanf("%d%d%d",&x[i],&y[i],&r[i]);
}
int ans=0;
for(int i=1;i<=n;i++){
if(check(i))ans++;
}
printf("%d\n",ans);
}
int main()
{
work();
return 0;
}
Codeforces Round #430 B. Gleb And Pizza的更多相关文章
- Codeforces Round #430 (Div. 2) 【A、B、C、D题】
[感谢牛老板对D题的指点OTZ] codeforces 842 A. Kirill And The Game[暴力] 给定a的范围[l,r],b的范围[x,y],问是否存在a/b等于k.直接暴力判断即 ...
- Codeforces Round #430 (Div. 2)
A. Kirill And The Game time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- 【Codeforces Round #430 (Div. 2) B】Gleb And Pizza
[链接]点击打开链接 [题意] 在这里写题意 [题解] 根据圆心到原点的距离这个东西判断一下圆在不在那个环里面就好 [错的次数] 0 [反思] 在这了写反思 [代码] #include <cst ...
- C - Ilya And The Tree Codeforces Round #430 (Div. 2)
http://codeforces.com/contest/842/problem/C 树 dp 一个数的质因数有限,用set存储,去重 #include <cstdio> #includ ...
- D. Vitya and Strange Lesson Codeforces Round #430 (Div. 2)
http://codeforces.com/contest/842/problem/D 树 二进制(路径,每个节点代表一位) #include <cstdio> #include < ...
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree
地址:http://codeforces.com/contest/842/problem/C 题目: C. Ilya And The Tree time limit per test 2 second ...
- Codeforces Round #448 (Div. 2) A. Pizza Separation【前缀和/枚举/将圆(披萨)分为连续的两块使其差最小】
A. Pizza Separation time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #430 (Div. 2) - D
题目链接:http://codeforces.com/contest/842/problem/D 题意:定义Mex为一个序列中最小的未出现的正整数,给定一个长度为n的序列,然后有m个询问,每个询问给定 ...
- Codeforces Round #430 (Div. 2) - B
题目链接:http://codeforces.com/contest/842/problem/B 题意:给定一个圆心在原点(0,0)半径为r的大圆和一个圆内的圆环长度d,然后给你n个小圆,问你有多少个 ...
随机推荐
- python 异步协程
"""A very simple co-routine scheduler. Note: this is written to favour simple code ov ...
- js基本包装类型和引用类型
回顾 1.什么是基本类型? 共5个.boolean,string,number,null,undefined. 2.什么是引用类型? 引用类型的值是对象,保存在堆内存中: 引用类型的变量实际上是一个指 ...
- 复习上学期的HTML+CSS(1)
自己跟着网上教程复习上学期的HTML+CSS,因为已经忘得差不多了,而且现在学的js也要以HTML+CSS为基础,坚持每天持续更新. n B/S 网络结构 Browser/Server 浏览器/ ...
- python Django之文件上传
python Django之文件上传 使用Django框架进行文件上传共分为俩种方式 一.方式一 通过form表单进行文件上传 #=================================== ...
- python基础——面向对象进阶下
python基础--面向对象进阶下 1 __setitem__,__getitem,__delitem__ 把对象操作属性模拟成字典的格式 想对比__getattr__(), __setattr__( ...
- html的特点及结构
html 语言就是开发网页的基础语言: html(超文本标记语言) 标记 : 该门语言是有标签来构成的. 学习html不用怎么去理解,只要需要记住标签的作用即可. html语言的特点: 1. html ...
- z-index的权重是叠加的
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- windows使用Win32DiskImager安装树莓派系统
首先去 官网 下载一个树莓派镜像. 然后使用Win32DiskImager这个工具安装. 不过试了以下好像不管用. 然后网上有ubuntu安装树莓派操作系统的方法. 于是就想我要是装树莓派不会还得装一 ...
- 学习React系列(五)——使性能最优
提高性能可分为两方面: 一.配置层面 二.代码层面 本文只从代码层面考虑: 一.避免重复渲染 这里要说一句: 当shouldComponentUpdate返回false的时候不触发render函数也就 ...
- 【转载】C++基本功和 Design Pattern系列 ctor & dtor
最近实在是太忙了,无工夫写呀.只能慢慢来了.呵呵,今天Aear讲的是class.ctor 也就是constructor, 和 class.dtor, destructor. 相信大家都知道const ...