水题(三角形与扇形面积计算sin()应用)
Posted nonames
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了水题(三角形与扇形面积计算sin()应用)相关的知识,希望对你有一定的参考价值。
J - Sincerely
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.
Input
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 ;
以上是关于水题(三角形与扇形面积计算sin()应用)的主要内容,如果未能解决你的问题,请参考以下文章