HDU 1140 War on Weather: distance between three-dimensional points

Source: Internet
Author: User

HDU 1140:http://acm.hdu.edu.cn/showproblem.php?pid=1140

The center of the Earth is (0,0,0), give you K-satellite and K-satellite three-dimensional coordinates (based on the center of the Center), M on the Earth's point and the M-point of the three-dimensional coordinates (based on the center of the Center), asked how many points are able to be covered by the satellite, the output quantity.

Ideas:

To find the length of the tangent of the satellite and the Earth, on earth, the length of the link with the satellite is less than the length of the tangent can be seen.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

#define PI ACOs ( -1.0) struct point {Double x, y, Z;}
  
P[110];
  
Double distance (point A, point B) {return (a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y) + (a.z-b.z) * (A.Z-B.Z);}
  
int n, m;
  
    void Solve () {double R = 20000.0/pi;
        while (~SCANF ("%d%d", &n, &m)) {if (!n &&!m) {break;
        for (int i = 0; i < n; ++i) {scanf ("%lf%lf%lf", &p[i].x, &p[i].y, &p[i].z);
        int cnt = 0;
        Point pp;
            for (int i = 0; i < m ++i) {scanf ("%lf%lf%lf", &pp.x, &pp.y, &pp.z);
                for (int j = 0; J < N; ++j) {Double D2 = p[j].x*p[j].x+p[j].y*p[j].y+p[j].z*p[j].z;
                Double L2 = d2-r*r;
                    if (distance (P[j], pp) <= L2) {cnt++;
                Break
 } printf ("%d\n", CNT);   }} HDU 1140 

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.