codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

842B.md (1897B)


      1 Source: https://codeforces.com/problemset/problem/842/B
      2 
      3 B. Gleb And Pizza
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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 *r**i*, and the center is given as a pair (*x**i*, *y**i*).
     24 
     25 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.
     26 
     27 Input
     28 
     29 First string contains two integer numbers *r* and *d* (0 ≤ *d* < *r* ≤ 500) — the radius of pizza and the width of crust.
     30 
     31 Next line contains one integer number *n* — the number of pieces of sausage (1 ≤ *n* ≤ 105).
     32 
     33 Each of next *n* lines contains three integer numbers *x**i*, *y**i* and *r**i* ( - 500 ≤ *x**i*, *y**i* ≤ 500, 0 ≤ *r**i* ≤ 500), where *x**i* and *y**i* are coordinates of the center of *i*-th peace of sausage, *r**i* — radius of *i*-th peace of sausage.
     34 
     35 Output
     36 
     37 Output the number of pieces of sausage that lay on the crust.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 8 4  
     45 7  
     46 7 8 1  
     47 -7 3 2  
     48 0 2 1  
     49 0 -2 2  
     50 -3 -3 1  
     51 0 6 2  
     52 5 3 1
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 2
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 10 8  
     65 4  
     66 0 0 9  
     67 0 0 10  
     68 1 0 1  
     69 1 0 2
     70 ```
     71 
     72 Output
     73 
     74 ```
     75 0
     76 ```
     77 
     78 Note
     79 
     80 Below is a picture explaining the first example. Circles of green color denote pieces of sausage lying on the crust.
     81 
     82  ![](https://espresso.codeforces.com/f81223a0b6c596bd36f93cf97967395194e23ccd.png)