标签:span str sha bsp not HERE href -o center
Physics cat likes to draw shapes and figure out their area. He starts by drawing a circle. Then inside the circle, he draws the triangle X, Y, Z - where Y is the center point of the circle, and X and Z touch the circumference of the circle. Please note that points X and Y always have the same x-coordinate.
Given L (the distance between Points X and Y) and A (the angle XYZ in degrees); help physics cat find the shaded area between the right side of the triangle and the circumference of the circle. And when we say help, we mean do all the work for him.
The first line of input is T – the number of test cases.
The first line of each test case is integers L and A (1 ≤ L ≤ 1000) (1 ≤ A ≤ 180).
OutputFor each test case, output on a line the area of the shaded region rounded to 6 decimal places.
Example3
1 90
2 180
10 30
0.285398
6.283185
1.179939
注意:sin()函数接受的是弧度制(用角度除去180).Π的定义
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <iostream> #include <algorithm> #include <iostream> #include<cstdio> #include<string> #include<cstring> #include <stdio.h> #include <string.h> //#define PI 3.1415926 using namespace std; const double PI = acos(-1.0); int main() { int n ; cin >> n ; while(n--) { double l , d , tr , y; scanf("%lf%lf" , &l , &d); y = l * l * PI ; y = d / 360 * y ; tr = sin(d /180.0 *PI) * 1 / 2.0 * l * l ; printf("%.6lf\n" , y-tr); } return 0 ; }
标签:span str sha bsp not HERE href -o center
原文地址:https://www.cnblogs.com/nonames/p/11290791.html