# include iostream include fstream include algorithm include math includ

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229``` ```#include #include #include #include #include using namespace std; ifstream in("foolsday.in"); ofstream out("foolsday.out"); double M_PI; const double eps = 1e-7; bool between(double a, double b, double x) { return (a - eps < x) && (x < b + eps); } struct angles { double first, second; angles(double a, double b) : first(a), second(b) { if (first < 0 ) first += 2*M_PI; if (second < 0 ) second += 2*M_PI; if (first > 2*M_PI) first -= 2*M_PI; if (second > 2*M_PI) second -= 2*M_PI; if (first < second && second - first < M_PI || first > second && first - second > M_PI) { double t = first; first = second; second = t; } if (first > second-eps) second += 2*M_PI; assert(first >= 0 && second >= 0 && second - first >= M_PI); } angles() {} void normalize() { if (first >= 2*M_PI && second >= 2*M_PI) { first -= 2*M_PI; second -= 2*M_PI; } if (first < 0) { first += 2*M_PI; second += 2*M_PI; } } bool fits(double x) { while (x - 2*M_PI > first) x-=2*M_PI; while (x <= second+eps) { if (between(first, second, x)) return true; x += 2*M_PI; } return false; } }; struct line { double a, b, c; line() {}; line(double a, double b, double c) : a(a),b(b),c(c) { normalize(); } void normalize() { double d = sqrt(a*a + b*b); a /= d; b /= d; c /= d; } }; ostream & operator << (ostream & o, angles const & a) { o << a.first <<' '<= 2*M_PI) alpha -=2*M_PI; for (int i = 0; i != 4; ++i) if (!an[i].fits(alpha)) return false; return true; } bool check(angles * an1, angles * an2, double alpha, double beta) { return check(an1, alpha) && check(an2, beta); } bool anless(angles const & a, angles const & b) { if (a.first < b.first) return true; if (a.first > b.first) return false; return a.second < b.second; } bool solve() { double a,b,c; double a1,b1,c1; in >> a >> b >> c >> a1 >> b1 >> c1; if (a > b) swap(a, b); if (a1 > b1) swap(a1, b1); double p = (a+b+c)/2; double h = 2*sqrt(p*(p-a)*(p-b)*(p-c))/a; int i = 0; line l[4]; l[0] = line(0, 1, h/2); l[1] = line(0, 1, -h/2); double k = sqrt(b*b-h*h); l[2] = getLine((a+k)/2, h/2, (a-k)/2,-h/2); l[3] = getLine(-(a+k)/2, -h/2, -(a-k)/2,h/2); angles an[8]; double d1 = c1/2; double d2 = sqrt(2*a1*a1+2*b1*b1-c1*c1)/2; if (d1 > d2) swap(d1, d2); double alpha = acos((d1*d1+d2*d2-a1*a1)/(2*d1*d2)); int j = 0; for (i = 0;i != 4; ++i) { an[i] = getValid(l[i], d1); an[4+i] = getValid(l[i], d2); an[4+i].first += alpha; an[4+i].second += alpha; an[4+i].normalize(); } double all[17]; j = 0; sort(an, an + 8, anless); for (i = 0;i != 8;++i) { all[j++] = an[i].first; all[j++] = an[i].second; } sort(all, all+16); all[16] = all[0]+2*M_PI; for (i = 0; i < 16;++i) { double x = 5.0069904867236339; for (j = 0;j != 8;++j) if (!an[j].fits(x)) break; if (j == 8) return true; for (j = 0;j != 8;++j) if (!an[j].fits(all[i])) break; if (j == 8) return true; } return false; } int main() { M_PI = atan2(0, -1); int N; in >> N; for (int i = 0;i != N;++i) if (solve()) out << "Yes\n"; else out << "No\n"; return 0; } ```