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 }

     

  • 相关阅读:
    长沙集训day6
    长沙集训day5(总结)
    长沙集训day4(总结)(爆零记)
    长沙集训day3(总结)(爆零记)
    长沙集训day2(总结)
    长沙集训day1(总结)
    p1324 dining(晚餐)
    p1156集合删数
    1034: [ZJOI2008]泡泡堂BNB
    清北学堂Day 6 游记
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7460758.html
Copyright © 2011-2022 走看看