zoukankan      html  css  js  c++  java
  • Lazy Physics Cat

    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 XYZ - 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 Yalways 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

    Copy

    3
    1 90
    2 180
    10 30
    

    output

    Copy

    0.285398
    6.283185
    1.179939
    

    题意:在圆里画三角,Y是原点,X,Z在圆上,A即圆半径,L三角形的角度,求右侧圆减三角形的面积

    #include <iostream>
    #include <stdio.h>
    #include <algorithm>
    #include <string.h>
    #include <math.h>
    #define PI acos(-1.0)
    using namespace std;
    int main()
    {
        int i,j,k;
        double ans,s,m,n;
        scanf("%d",&k);
        for(i=0;i<k;i++)
        {
            scanf("%lf%lf",&m,&n);
            s=(PI*m*m*n/360.0);
            ans=m*m*sin(n/180*PI)/2.0;
            ans=s-ans;
            printf("%lf
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    day03 字符串
    day02 运算符和编码
    day01 初识Python
    windows 安装yaml支持和pytest支持等
    Python自动补全缩写意义
    关于python接口测试connect error
    关于Python的post请求报504错误
    python函数参数*args **kwargs
    利用Python语言Appium启动ios app
    shell 中| 用法
  • 原文地址:https://www.cnblogs.com/zcy19990813/p/9702814.html
Copyright © 2011-2022 走看看