zoukankan      html  css  js  c++  java
  • 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
    ",ans);
    }
    
    int main()
    {
    	work();
    	return 0;
    }
    
  • 相关阅读:
    vue-quill-editor富文本编辑器使用
    vue中this.$router.push()路由传值和获取的两种常见方法
    在 Vue.js项目中如何定义全局变量&全局函数
    vue中利用provide和inject实现页面刷新(无白屏)重载组件
    linux 发送get post命令
    java 反射结合hibernate-validator 注解校验对象数据合法性
    开发过程工具集
    java 创建文件夹及文件写入数据到excel
    java文件不存在就创建_Java中创建并写文件的5种方式【转载】
    java 字符串左补齐
  • 原文地址:https://www.cnblogs.com/Yuzao/p/7451695.html
Copyright © 2011-2022 走看看