Nyoj710 alien supply station [greedy]

Source: Internet
Author: User

Alien supply site time limit: 1000 MS | memory limit: 65535 kb difficulty: 3
Description

Aliens refer to smart life beyond the Earth. It doesn't matter whether aliens are as long as people on Earth, but at least it should be in line with our current understanding of the basic forms of life. For example, what we know is that no matter what life is inseparable from liquid water, it is also a complex organism based on chemical elements carbon (C) organic molecules.

Dr. Kong, 42, has been persistently watching the planet ZDM-777 for more than a decade. The red planet, known as the god of war, has become so fascinated. He has made some exciting discoveries over the past decade. The surface of the ZDM-777 planet has significant variation in light and shade, and dr. Kong has carefully studied these regions for many years and has drawn more detailed maps. He believes that the hidden areas are land, while the bright areas are lakes and oceans. He has always believed that there must be traces of life where there is water. Dr. Kong has a strong hunch that today will be the most memorable day of his life.
This evening's observation conditions are really unprecedented, ZDM-777 planet is also very bright, showing a clear dark red circle spot in the radio telescope. Or those familiar areas of light and shade and the crown, just, etc. dr. Kong seems to have caught what he once saw. What is that. He kept his eyes wide as much as possible and carefully recognized. Oh, that's right. On a straight line, several Aurora points are connected to the bright area of the planet. A few minutes later, the aurora point disappears.

Dr. Kong boldly guessed that there must be creatures in the lakes and oceans on the ZDM-777 planet. Those Aurora points are supply stations on the planet of ZDM-777, regularly offering them life-saving supplies.

It is best to set the line to the X axis, where the Aurora points are on the X axis, and N Bright Areas P1, P2 ,... PN is distributed around several Aurora points.



Then dr. Kong was surprised to find that all the bright area PI was in the Aurora circle with a radius of R. If you remove an aurora spot, some bright area PJ will not be in the coverage area.

Dr. Kong wants to know how many Aurora points need to cover all the lakes and oceans.
Input
Row 1: k indicates the number of groups of Token test data.
Next, we will try the data for each group:
Row 3: n r
2nd ~ N + 1 rows: PXI Pyi (I = 1 ,....., N)

[Constraints]
2 ≤ k ≤ 5 1 ≤ r ≤ 50 1 ≤ n ≤ 100-100 ≤ Roxy Pyi ≤ 100 | Pyi | ≤ r
R and PXI Pyi are all integers. There is a space between data.
Output
For each group of benchmark data, output one line: the minimum required Aurora points.
Example Input
23 21 2-3 12 11 55 5
Example output
21
Source
Sixth Henan Program Design Competition

Interval Selection

#include <stdio.h>#include <math.h>#include <algorithm>using std::sort;struct Node{double left, right;} arr[102];bool cmp(Node x, Node y){return x.right < y.right;}int main(){int t, n, count;double x, y, r, temp;scanf("%d", &t);while(t--){scanf("%d%lf", &n, &r);for(int i = 0; i < n; ++i){scanf("%lf%lf", &x, &y);temp = sqrt(r*r - y*y);arr[i].left = x - temp;arr[i].right = x + temp;}sort(arr, arr + n, cmp);temp = arr[0].right;count = 1;for(int i = 1; i < n; ++i){if(temp < arr[i].left){temp = arr[i].right;++count;}}printf("%d\n", count);}return 0;}


Nyoj710 alien supply station [greedy]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.