zoukankan      html  css  js  c++  java
  • hdu-5858 Hard problem(数学)

    题目链接:

    Hard problem

    Time Limit: 2000/1000 MS (Java/Others)   

     Memory Limit: 65536/65536 K (Java/Others)


    Problem Description
    cjj is fun with math problem. One day he found a Olympic Mathematics problem for primary school students. It is too difficult for cjj. Can you solve it?


    Give you the side length of the square L, you need to calculate the shaded area in the picture.

    The full circle is the inscribed circle of the square, and the center of two quarter circle is the vertex of square, and its radius is the length of the square.
     
    Input
    The first line contains a integer T(1<=T<=10000), means the number of the test case. Each case contains one line with integer l(1<=l<=10000).
     
    Output
    For each test case, print one line, the shade area in the picture. The answer is round to two digit.
     
    Sample Input
    1
    1
     
    Sample Output
    0.29
     
    题意:
     
    求变成为l的正方形中阴影部分的面积;
     
    思路:
     
    建坐标系积分就好了;以正方形的中心为原点,以对角线为水平轴,然后得到两个圆的方程,联立求交点得到积分区间,然后积分,积分的时候借用三角函数;
     
    AC代码:
     
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #include <bits/stdc++.h>
    #include <stack>
    #include <map>
     
    using namespace std;
     
    #define For(i,j,n) for(int i=j;i<=n;i++)
    #define mst(ss,b) memset(ss,b,sizeof(ss));
     
    typedef  long long LL;
     
    template<class T> void read(T&num) {
        char CH; bool F=false;
        for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
        for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
        F && (num=-num);
    }
    int stk[70], tp;
    template<class T> inline void print(T p) {
        if(!p) { puts("0"); return; }
        while(p) stk[++ tp] = p%10, p/=10;
        while(tp) putchar(stk[tp--] + '0');
        putchar('
    ');
    }
     
    const LL mod=1e9+7;
    const double PI=acos(-1.0);
    const int inf=1e9;
    const int N=5e5+10;
    const int maxn=(1<<20)+14;
    const double eps=1e-12;
    
    
    double s;
    double solve(double x)
    {
        return (2*x+sin(2*x))/4;
    }
    inline void Init()
    {
         s=sqrt(7)/2;
         //cout<<s<<endl;
         s+=solve(asin(sqrt(14)/4))-4*solve(asin(sqrt(14)/8));
    }
    int main()
    {
        int t;
        read(t);
        Init();
        while(t--)
        {
            double l;
            scanf("%lf",&l);
            printf("%.2lf
    ",s*l*l);
        }
        return 0;
    }
    

      

  • 相关阅读:
    敏捷 咨询师 火星人陈勇博客牛人
    fpa 功能点分析法
    cto职责
    lexus
    c
    zz
    百度效率云
    zz
    产品研发体系中的需求承接与输出
    ESAPI学习笔记
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5784688.html
Copyright © 2011-2022 走看看