这道题较为简单?
事实上我们只用把分型看成两颗自相似树就可以了。
我的思路如下:
从 长出的子树相似比 ,从 长出的子树相似比 。
整幅画有界当且仅当两支每代都严格收缩,即 且 。
化成整数坐标判断:
且
两式同时成立输出 YES,否则 NO。
代码
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define bye return 0
#define hello ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define i_ak_all int main()
using namespace std;
i_ak_all{
hello;
ll t;
if (!(cin >> t)){
bye;
}
while (t--){
ll x0, y0, x1, y1, x2, y2;
cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2;
ll r2 = x0 * x0 + y0 * y0;
auto st = [&](ll dx, ll dy)->int{
ll d2 = dx * dx + dy * dy;
if (d2 < r2){
return 0;
}
if (d2 == r2){
if (dx == x0 && dy == y0){
return 3;
}
return 1;
}
return 2;
};
ll a = st(x1 - x0, y1 - y0), b = st(x2 - x0, y2 - y0);
if (a == 2 || b == 2 || a == 3 || b == 3){
cout << "NO" << endl;
continue;
}
if (a == 1 && b == 1){
if ((x1 - x0) != (x2 - x0) || (y1 - y0) != (y2 - y0)){
cout << "NO" << endl;
continue;
}
}
cout << "YES" << endl;
} bye;
}