Luogu P1652 Round Problem Solution

topic portal

This question also tests your understanding of geometry:

When the circle and the circle have no common point and one circle is outside the other circle, it is called the circle is separated from the circle.

When the distance between the centers of the circles is greater than the sum of the radii of the two circles, it is called the outer distance of the two circles;

When the distance between the centers of the circles is less than the absolute value of the difference between the radii of the two circles, it is called the inclusion of two circles.

After knowing that, the topic is easy to do:

#include<bits/stdc++.h>
using namespace std;
int n,xx0,xx1,yy0,yy1,ans;
struct node{
    int x,y,r;
}a[55];
int JS(int x,int y,node a){
    if((x-a.x)*(x-a.x)+(y-a.y)*(y-a.y)<=(a.r)*(a.r)) return 1;
    return 0;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;++i) cin>>a[i].x;
    for(int i=1;i<=n;++i) cin>>a[i].y;
    for(int i=1;i<=n;++i) cin>>a[i].r;
    cin>>xx0>>yy0>>xx1>>yy1;
    for(int i=1;i<=n;++i)
        if(JS(xx0,yy0,a[i])^JS(xx1,yy1,a[i])) ans++;
    printf("%d\n",ans);return 0;
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325228673&siteId=291194637