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 }

     

  • 相关阅读:
    vsftpd匿名用户实验
    CentOS7 突然连不上网,报错"FailedtostartLSB:Bring up/down networking"
    搭建Java Web开发环境
    Starting named:[FAILED] named启动失败
    CentOS6克隆虚拟机报错Device eth0 does not seem to be present,delaying initialization.
    ADD requires at least two arguments
    mysql 5.7密码策略修改
    JavaScript手册
    vs编译生成之后报错
    vs编译生成之后报错
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7460758.html
Copyright © 2011-2022 走看看