I. Circles

Codeforces
IDCF10185I
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Let d be the diameter of a circle with center c = (a, b). A square has been drawn inside that circle such that its vertices lies at the circle's circumference. Four circles have been drawn on the square's sides such that the diameter of each circle is the side of the square, as shown in the figure below. Your task is to calculate the shaded area in the figure for a given d. Can you? The first line contains an integer T (1 ≤ T ≤ 105), in which T is the number of test cases. Each test case consists of a line containing an three integers a, b, and d ( - 109 ≤ a, b ≤ 109) (1 ≤ d ≤ 109), giving the center and the diameter of a circle. For each test case, print a single line containing shaded area. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6. ## Input The first line contains an integer T (1 ≤ T ≤ 105), in which T is the number of test cases.Each test case consists of a line containing an three integers a, b, and d ( - 109 ≤ a, b ≤ 109) (1 ≤ d ≤ 109), giving the center and the diameter of a circle. ## Output For each test case, print a single line containing shaded area.Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6. [samples]
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case, let $ d \in \mathbb{R}^+ $ be the diameter of a circle centered at $ (a, b) \in \mathbb{R}^2 $. A square is inscribed in the circle such that its vertices lie on the circumference. Four semicircles are drawn outwardly on each side of the square, with each side as diameter. **Constraints** 1. $ 1 \leq T \leq 10^5 $ 2. $ -10^9 \leq a, b \leq 10^9 $ 3. $ 1 \leq d \leq 10^9 $ **Objective** Compute the shaded area, defined as the area of the four semicircles minus the area of the inscribed square. Let $ s $ be the side length of the square. Since the square is inscribed in a circle of diameter $ d $, the diagonal of the square equals $ d $: $$ s\sqrt{2} = d \quad \Rightarrow \quad s = \frac{d}{\sqrt{2}} $$ Area of the square: $$ A_{\text{square}} = s^2 = \frac{d^2}{2} $$ Each semicircle has diameter $ s $, so radius $ r = \frac{s}{2} = \frac{d}{2\sqrt{2}} $. Area of one semicircle: $$ \frac{1}{2} \pi r^2 = \frac{1}{2} \pi \left( \frac{d}{2\sqrt{2}} \right)^2 = \frac{1}{2} \pi \cdot \frac{d^2}{8} = \frac{\pi d^2}{16} $$ Total area of four semicircles: $$ 4 \cdot \frac{\pi d^2}{16} = \frac{\pi d^2}{4} $$ Shaded area: $$ A_{\text{shaded}} = \frac{\pi d^2}{4} - \frac{d^2}{2} = d^2 \left( \frac{\pi}{4} - \frac{1}{2} \right) $$ **Output** For each test case, output: $$ d^2 \left( \frac{\pi}{4} - \frac{1}{2} \right) $$
API Response (JSON)
{
  "problem": {
    "name": "I. Circles",
    "description": {
      "content": "Let d be the diameter of a circle with center c = (a, b). A square has been drawn inside that circle such that its vertices lies at the circle's circumference. Four circles have been drawn on the squa",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10185I"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Let d be the diameter of a circle with center c = (a, b). A square has been drawn inside that circle such that its vertices lies at the circle's circumference. Four circles have been drawn on the squa...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case, let $ d \\in \\mathbb{R}^+ $ be the diameter of a circle centered at $ (a, b) \\in \\mathbb{R}^2 $.  \nA square...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments