B - Two Rings 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 250

問題文

xy 平面上に 2 つの円 C_1, C_2 があります。ただし、本問題において円とは円周のことを指します。
C_1 は中心の座標が (X_1, Y_1) で半径が R_1 です。
C_2 は中心の座標が (X_2, Y_2) で半径が R_2 です。
C_1 と円 C_2 が共有点を持つかどうかを判定してください。言い換えると、点 (X_1, Y_1) からの距離が R_1 であり、かつ点 (X_2, Y_2) からの距離が R_2 であるような点が 1 個以上存在するかどうかを判定してください。

T 個のテストケースが与えられるのでそれぞれについて答えを求めてください。

制約

  • 1 \leq T \leq 100
  • 0 \leq X_1, Y_1, X_2, Y_2 \leq 10^9
  • 1 \leq R_1, R_2 \leq 10^9
  • 入力される値は全て整数

入力

入力は以下の形式で標準入力から与えられる。ここで \mathrm{case}_ii 番目のテストケースを意味する。

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

各テストケースは以下の形式で与えられる。

X_1 Y_1 R_1 X_2 Y_2 R_2

出力

T 行出力せよ。i 行目には i 番目のテストケースの答えを出力せよ。
各テストケースでは、円 C_1 と円 C_2 が共有点を持つ場合は Yes を、そうでない場合は No を出力せよ。


入力例 1

7
0 0 2 2 3 2
0 0 2 2 3 1
1 2 5 3 2 1
5 4 2 8 8 3
2 1 5 5 1 2
0 0 1 0 0 1
0 0 500000000 1 1000000000 500000000

出力例 1

Yes
No
No
Yes
Yes
Yes
No

例えば 1 番目のテストケースでは、C_1C_2 の位置関係は以下の図のようになります。

image

Score : 250 points

Problem Statement

There are two circles C_1 and C_2 on the xy-plane. In this problem, a circle refers to the circumference.
Circle C_1 has its center at (X_1, Y_1) and radius R_1.
Circle C_2 has its center at (X_2, Y_2) and radius R_2.
Determine whether circles C_1 and C_2 have a common point. In other words, determine whether there exists at least one point whose distance from (X_1, Y_1) is R_1 and whose distance from (X_2, Y_2) is R_2.

You are given T test cases; solve each one.

Constraints

  • 1 \leq T \leq 100
  • 0 \leq X_1, Y_1, X_2, Y_2 \leq 10^9
  • 1 \leq R_1, R_2 \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format, where \mathrm{case}_i denotes the i-th test case:

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

Each test case is given in the following format:

X_1 Y_1 R_1 X_2 Y_2 R_2

Output

Output T lines. The i-th line should contain the answer for the i-th test case.
For each test case, output Yes if circles C_1 and C_2 have a common point, and No otherwise.


Sample Input 1

7
0 0 2 2 3 2
0 0 2 2 3 1
1 2 5 3 2 1
5 4 2 8 8 3
2 1 5 5 1 2
0 0 1 0 0 1
0 0 500000000 1 1000000000 500000000

Sample Output 1

Yes
No
No
Yes
Yes
Yes
No

For example, in the first test case, the relative positions of C_1 and C_2 are as shown in the following figure.

image