码迷,mamicode.com
首页 > 其他好文 > 详细

水题(三角形与扇形面积计算sin()应用)

时间:2019-08-02 20:18:27      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:span   str   sha   bsp   not   HERE   href   -o   center   

J - Sincerely

Gym - 101350J

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).

Output

For each test case, output on a line the area of the shaded region rounded to 6 decimal places.

Example
Input
3
1 90
2 180
10 30
Output
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()应用)

标签:span   str   sha   bsp   not   HERE   href   -o   center   

原文地址:https://www.cnblogs.com/nonames/p/11290791.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!