NYOJ710 Alien Supply Station (greedy)

Source: Internet
Author: User
Tags printf time limit
the aliens ' supply station.Time limit: Ms | Memory limit: 65535 KB Difficulty: 3 description

Aliens refer to Intelligent life beyond the Earth. The aliens are not as important as the people on Earth, but at least they should conform to our current understanding of the basic forms of life. For example, any life we know can be separated from liquid water, and are complex organisms that are based on organic molecules of chemical element carbon (C).

The 42-year-old astronomer Dr. Kong has been clinging to the ZDM-777 planet for more than 10 years, a red planet known as the "Ares" that fascinates him. For the past more than 10 years, he has often had some exciting discoveries. The surface of the ZDM-777 planet has a noticeable change of light and shade, and Dr Kong has studied it carefully for many years and has mapped out more detailed maps. He believed that the dark areas were land, while the bright areas were lakes and oceans. He has always believed that there is a place of water, there must be traces of life. Dr Kong has a strong feeling that today will be the most memorable day of his life.
This night's observation conditions are really unprecedented good, the ZDM-777 planet is also very bright, in the radio telescope shows a clear dark red spot. Or the familiar shades and poles, but, and so on, Dr. Kong seems to be catching what he has seen, what it is, looming. He opened his eyes as wide as he could and identified them carefully. Oh, yes, in a straight line, there are several aurora dots connected to the bright area of the planet, and a few minutes later, the Aurora Point disappears.

Dr Kong boldly suspects that there must be creatures in the lakes and oceans of the ZDM-777 planet. The aurora borealis is the supply station on the ZDM-777 Planet, which regularly provides life-sustaining supplies to these creatures.

It can be set, the line is the x-axis, the Aurora point is on the x-axis, n bright area p1,p2, ... PN is distributed around a number of aurora spots.



Then, Dr Kong has a startling discovery that all the bright-zone pi are in a circle of aurora dots with a radius of R. Remove an aurora dot and there will be some bright areas PJ is not in the coverage area. Dr Kong wants to know how many aurora dots are needed to cover all the lakes and oceans. Enter the first line: K indicates how many sets of test data are available.
Next to each set of test data:
Line 1th: N R
Line 2~n+1: PXi PYi (i=1,....., N)

"Constraint conditions"
2≤k≤5 1≤r≤50 1≤N≤100-100≤PXI pyi≤100 | PYi | ≤r
R, the PXi pyi are all integers. There is a space between the data.
Output for each set of test data, output one line: Minimum number of aurora points required. Sample input

23 21 2-3 12 11 55 5
Sample output
21st
/* This question our team wrong 11 times, but if Xiao Guo patient good, estimate can not time:2014-11-16 0:06 * * #include <cstdio> #include <cstring> #include <cmath
> #include <algorithm> using namespace std;
const int max=1020; struct node{double s,e;}
S[max];
    BOOL CMP (Node A,node b) {return a.s<b.s;} int main () {int n;double D;
    int ncase=0;
    int T;
    scanf ("%d", &t);
        while (t--) {scanf ("%d%lf", &n,&d);
        Double x, y;
        int k=0;
            for (int i=0;i<n;i++) {scanf ("%lf%lf", &x,&y);
            if (Y<=d) {s[i].e=x+sqrt (d*d-y*y);
            S[I].S=X-SQRT (D*d-y*y);
            }}/* if (k==0) {printf ("Case%d: -1\n", ++ncase);
        Continue
        }*/sort (s,s+n,cmp);
        Double pos=s[0].e;
        int Ans=1;
			for (int i=0;i<n;i++) {if (S[i].e<=pos) {///Note consider this condition POS=S[I].E;
                }else if (s[i].s>pos) {ans++;
     POS=S[I].E;       }} printf ("%d\n", ans);
    printf ("Case%d:%d\n", ++ncase,ans);
} return 0;
  }

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.