欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

G-Circles

程序员文章站 2024-03-20 21:31:34
...

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.

G-Circles

Your task is to calculate the shaded area in the figure for a given d. Can you?

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.

Example
Input
1
2 3 8
Output
32

题记:给出圆心,半径,求图中阴影部分面积
先求出四个小圆的半圆面积,再减去大圆面积,最后加上正方形面积,求出阴影面积。

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int t;
ll a, b, d;

int main()
{
    scanf("%d", &t);
    while (t--)
    {
        scanf("%lld%lld%lld", &a, &b, &d);
        printf("%.10f\n", (d * d) * 1.0 / 2);
    }
    return 0;
}

推荐阅读