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;
    }
    

      

  • 相关阅读:
    多个表单如何同时验证
    vue+element 动态表单验证
    ‘Maximum call stack size exceeded’错误的解决方法
    select下拉框option的样式修改
    vue项目打包之后样式错乱问题,如何处理
    11_我拥有了属于自己的公众号了
    10_更改自己的ID
    001_Spring之xml的class的补全(eclipse)
    01_Navicat的快捷键学习
    web开发资源网站汇总
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5784688.html
Copyright © 2011-2022 走看看