题解:P15056 [UOI 2023 II Stage] Unenslaved puppy
liangcha_crush · · 题解
P15046
思路
考虑初中距离公式,
代码
#include<bits/stdc++.h>
using namespace std;
int n;
double x1,y1,x2,y2,p,r;
int check(double x,double y,double p,double r){
double len=sqrt(1.0*pow(p-x,2)+1.0*pow(y,2));
if(len<=r)return 1;
return 0;
}
signed main(){
cin>>n>>x1>>y1>>x2>>y2;
for(int i=1;i<=n;i++){
cin>>p>>r;
int c1=check(x1,y1,p,r);//求与圆的关系
int c2=check(x2,y2,p,r);
if(c1^c2){//一个外,一个内
cout<<"NO"<<endl;
cout<<i;
return 0;
}
}
cout<<"YES";
return 0;
}