“红旗杯”第十五届黑龙江省大学生程序设计竞赛——August

Setiuo...原创OnlineJudgeC++签到大约 1 分钟

“红旗杯”第十五届黑龙江省大学生程序设计竞赛——August

Problem Description

“Remember when I pulled up and said get in the car, and then cancelled my plans just in case you’d call, back when I was living for the hope of it all.”

After death by a thousand cuts, he found his love. He has two parameter a and b, and he wants to show his lover a piece of drawing bounded by the following math curves.

{y=a2(xa)2y=a2(x+a)2y=2bπ(arccos(x+aa)π)y=2bπ(arcsin(xaa)π2) \begin{cases} y = \sqrt{a^2 - (x-a)^2} \\ y = \sqrt{a^2 - (x+a)^2} \\ y = \frac{2b}{\pi} \left( \arccos \left(\frac{x+a}{a}\right) - \pi \right) \\ y = \frac{2b}{\pi} \left( \arcsin \left(\frac{x-a}{a}\right) - \frac{\pi}{2} \right) \end{cases}

Now his lover wants to know the area bounded by the close curve. Can you tell him?

Input

The first line contains T (1 ≤ T ≤ 1000), the count of testcases.

Then the next T lines, each of them contains two integer a and b (1 ≤ a,b ≤ 1000).

Output

For each test case, output a number for the answer with an absolute or relative error of at most 10410^{-4}.

Precisely speaking, assume that your answer is a and and the jury’s answer is b, your answer will be considered correct if abmax{1,b}\frac{|a-b|}{max\{1,|b|\}}10410^{-4}, where max{x,y} means the maximum of x and y and |x| means the absolute value of x.

Sample Input

2 3 4 1000 1000

Sample Output

76.27433388 7141592.65358979

Hint

August sipped away like a bottle of wine. This is the rendered picture for the example.

Code

#include <iostream>
#include <ctime> 
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
using namespace std;
const double PI = 3.1415926;
int main()
{
    int t;
    cin >> t;
    int a, b;
    while (t--) {
        cin >> a >> b;
        double area = 0;
        area = PI * a * a;
        area += 4 * a * b;
        printf("%.2f\n", area);
    }
    return 0;
}
你认为这篇文章怎么样?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.14.7