zoukankan      html  css  js  c++  java
  • HDU 5858Hard problem

    Hard problem

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 38    Accepted Submission(s): 23


    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
     
    Author
    BUPT
     
    求大圆,小圆面积的交x,2*(小圆面积-x)就是答案。
    /* ***********************************************
    Author        :guanjun
    Created Time  :2016/8/18 12:33:04
    File Name     :p1002.cpp
    ************************************************ */
    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    #include <stdio.h>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <iomanip>
    #include <list>
    #include <deque>
    #include <stack>
    #define ull unsigned long long
    #define ll long long
    #define mod 90001
    #define INF 0x3f3f3f3f
    #define maxn 10010
    #define cle(a) memset(a,0,sizeof(a))
    const long double PI=acos(-1.0);  
    const ull inf = 1LL << 61;
    const double eps=1e-5;
    using namespace std;
    priority_queue<int,vector<int>,greater<int> >pq;
    struct Node{
        int x,y;
    };
    struct cmp{
        bool operator()(Node a,Node b){
            if(a.x==b.x) return a.y> b.y;
            return a.x>b.x;
        }
    };
    
    bool cmp(int a,int b){
        return a>b;
    }
    struct Round{
        double x,y;
        double r;
        double K(double x){
            return x*x;
        }
        double Dis(Round a,Round b){
            return sqrt(K(a.x-b.x)+K(a.y-b.y));
        }
        double Intersection_area(Round a,Round b){  
            double dis=Dis(a,b);  
            if(a.r==0||b.r==0||dis>=a.r+b.r)return 0;  
            else if(dis<=fabs(a.r-b.r))return PI*K(min(a.r,b.r));  
            else{  
                double angA=2*acos( (K(a.r)+K(dis)-K(b.r))/(2*a.r*dis) );  
                double angB=2*acos( (K(b.r)+K(dis)-K(a.r))/(2*b.r*dis) );  
                double areaA=K(a.r)*(angA-sin(angA))/2;  
                double areaB=K(b.r)*(angB-sin(angB))/2;  
                return areaA+areaB;  
            }  
        } 
    }a,b;
    int main()
    {
        #ifndef ONLINE_JUDGE
        //freopen("in.txt","r",stdin);
        #endif
        //freopen("out.txt","w",stdout);
        int n;
        cin>>n;
        double l;
        while(n--){
            scanf("%lf",&l);
            a.x=l/2.,a.y=l/2.,a.r=l/2.;
            b.x=l,b.y=0.,b.r=l;
            double ans=PI*l*l/2.-2*a.Intersection_area(a,b);
            printf("%.2f
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make s
    ScrollView 定位
    Fragment获取Activity,Activity获取Fragment
    Popupwindow全屏问题
    bzoj千题计划310:bzoj5285: [Hnoi2018]寻宝游戏(思维题+哈希)
    bzoj千题计划309:bzoj4332: JSOI2012 分零食(分治+FFT)
    2016vijos 1-3 兔子的晚会(生成函数+倍增FWT)
    bzoj千题计划308:bzoj4589: Hard Nim(倍增FWT+生成函数)
    bzoj千题计划307:bzoj5248: [2018多省省队联测]一双木棋
    cdqz2017-test10-加帕里图书馆(区间DP & 简单容斥)
  • 原文地址:https://www.cnblogs.com/pk28/p/5784852.html
Copyright © 2011-2022 走看看