链接:https://ac.nowcoder.com/acm/contest/8564/H
来源:牛客网
圆
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 524288K,其他语言1048576K
64bit IO Format: %lld
题目描述
scimoon 做不出题,随手在纸上画了两个正圆
第一个圆圆心为 (x1,y1) ,半径为 r1
第二个圆圆心为 (x2,y2) ,半径为 r2
这两个圆的圆弧有没有交呢
输入描述:
第一行一个正整数 T,表示数据组数
接下来 T 行,每行六个整数,分别为 x1,y1,r1,x2,y2,r2 ,意义如题中描述一致
输出描述:
输出共T行
对于每组数据,若有交则输出 YES,否则输出 NO
示例1
输入
复制
1
1 1 1 1 2 1
输出
复制
YES
备注:
对于所有数据,
题意:给出你两个圆,圆心+半径,判断两个是否相交
思路:
这个题其实画个图就行了
1. 包含(大的包含小的)
2. 相离这样没有
3. 相交或者相切 都有交点
关键是包含是你把那个大圆和小圆分开就行。
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#include <immintrin.h>
#pragma GCC optimize(2)
#include <map>
#include <queue>
#include <string>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include <algorithm>
#include <math.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<ll,ll> pii;
#define mem(a,x) memset(a,x,sizeof(a))
#define debug(x) cout << #x << ": " << x << endl;
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<=(b);++i)
#define repr(i,b,a) for(int i=int(b);i>=(a);--i)
const int maxn=1e6+1010;
#define inf 0x3f3f3f3f
#define sf scanf
#define pf printf
const int mod=998244353;
const int MOD=10007;
inline int read() {
int x=0;
bool t=false;
char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')t=true,ch=getchar();
while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
return t?-x:x;
}
vector<ll> m1;
vector<ll> m2;
priority_queue<ll , vector<ll> , greater<ll> > mn;//上 小根堆 小到大
priority_queue<ll , vector<ll> , less<ll> > mx;//下 大根堆 大到小
map<ll,ll>mp;
ll n,m;
#define read read()
int main(){
int t;
cin>>t;
while(t--){
double x,y,z,xx,yy,zz;
cin>>x>>y>>z>>xx>>yy>>zz;
if(z>zz){///z半径小
swap(zz,z);
swap(xx,x);
swap(yy,y);
}
double c=sqrt((xx-x)*(xx-x)+(yy-y)*(yy-y));
if(c>zz+z) cout<<"NO"<<endl;
else if(zz-c>z){
cout<<"NO"<<endl;
}else cout<<"YES"<<endl;
}
return 0;
}
京公网安备 11010502036488号