zoukankan      html  css  js  c++  java
  • B. Gleb And Pizza

    B. Gleb And Pizza
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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.

    Examples
    Input
    8 4
    7
    7 8 1
    -7 3 2
    0 2 1
    0 -2 2
    -3 -3 1
    0 6 2
    5 3 1
    Output
    2
    Input
    10 8
    4
    0 0 9
    0 0 10
    1 0 1
    1 0 2
    Output
    0
    Note

    Below is a picture explaining the first example. Circles of green color denote pieces of sausage lying on the crust.

    就是直接判断就够了,感觉是考数学的.
     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 int main(){
     4     int r,d,n,m=0;
     5     scanf("%d%d%d",&r,&d,&n);
     6     for(int i=0;i<n;i++){
     7         int x,y,z;
     8         scanf("%d%d%d",&x,&y,&z);
     9         double k=sqrt(x*x+y*y);
    10         if(k<=r&&k>=(r-d)){
    11             if((k+z)<=r&&(k-z)>=(r-d)){
    12                 m++;
    13             }
    14         }
    15     }
    16     printf("%d
    ",m);
    17     return 0;
    18 }

     

  • 相关阅读:
    macbook如何清理磁盘中的“容器中的其他宗卷”
    Maven本地仓库与远程仓库配置
    查看MySQL库、表所占磁盘空间大小
    数据库操作
    Mac Mysql初始密码重置
    Vue 性能优化经验总结
    【读书笔记】对象创建摘录
    【读书笔记】 函数柯里化
    js实现仿windows文件按名称排序
    本来想偷懒的今天,想了想,还是写一篇吧,前端登录界面,用的BOOTSTRAP
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7460758.html
Copyright © 2011-2022 走看看