Description
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).
Output
For each test case, output on a line the area of the shaded region rounded to 6 decimal places.
Sample Input
3 1 90 2 180 10 30Sample Output
0.285398 6.283185 1.179939
题解:一个圆,给你一个角度,画一个等要三角形,用扇形减去三角形即为所求。
代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn = 1e5+5;
const double Pi = acos(-1);
const int INF = 0x3f3f3f3f;
typedef long long ll;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int r,c;
scanf("%d%d",&r,&c);
double sum1,sum2;
sum1=r*r/2.0*sin(c*Pi/180);
sum2=(double)r*r*Pi*c/360;
printf("%.6lf\n",sum2-sum1);
}
return 0;
}