• HDU 1071 The area(求三个点确定的抛物线的面积,其中一个点是顶点)


    传送门:

    http://acm.hdu.edu.cn/showproblem.php?pid=1071

    The area

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 12095    Accepted Submission(s): 8490


    Problem Description
    Ignatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and a straight line. The picture below shows the area. Now given all the intersectant points shows in the picture, can you tell Ignatius the area of the land?

    Note: The point P1 in the picture is the vertex of the parabola.

     
    Input
    The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
    Each test case contains three intersectant points which shows in the picture, they are given in the order of P1, P2, P3. Each point is described by two floating-point numbers X and Y(0.0<=X,Y<=1000.0).
     
    Output
    For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.
     
    Sample Input
    2 5.000000 5.000000 0.000000 0.000000 10.000000 0.000000 10.000000 10.000000 1.000000 1.000000 14.000000 8.222222
     
    Sample Output
    33.33 40.69
    Hint
    For float may be not accurate enough, please use double instead of float.
     
    Author
    Ignatius.L
     
    题目意思:
    告诉你三个点,有一个点抛物线顶点,问你这三个点在抛物线中确定的面积
     
    分析:
    设抛物线y=a(x-b)^2+c   p1总是抛物线的顶点
        所以根据p1和另外随便一个点我们可以确定抛物线方程中的所有参数
        直线方程y=kx+d;
        抛物线方程减去直线方程的积分就是二者形成的面积
        面积就是a(x-b)^2+c-kx-d的积分
     
    code:
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    double a,b,c,k,d;
    double f(double x)//积分
    {
        return a*x*x*x/3-(2*a*b+k)*x*x/2+(a*b*b+c-d)*x;
    }
    int main()
    {
        /*
        设抛物线y=a(x-b)^2+c p1总是抛物线的顶点
        直线方程y=kx+d;
        面积就是a(x-b)^2+c-kx-d的积分
        */
        double x1,y1,x2,y2,x3,y3;
        int t;
        scanf("%d",&t);
        while(t--)
        {
            scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
            c=y1;
            b=x1;
            a=(y2-c)/((x2-b)*(x2-b));
            k=(y3-y2)/((x3-x2));
            d=y2-k*x2;
            printf("%0.2lf
    ",f(x3)-f(x2));
        }
        return 0;
    }
     
  • 相关阅读:
    模拟器登陆
    mab算法
    用户投票排名算法总结
    vue中路由
    利用ajax全局设置实现拦截器
    对于 前端请求Django 后端服务出现403 Forbidden (CSRF token missing or incorrect.) 问题的解析
    Datatable 插入一行数据到第一行
    Datatable 导出到execl 官网demo
    jquery cookie操作
    on绑定事件支持的事件类型
  • 原文地址:https://www.cnblogs.com/yinbiao/p/9327444.html
Copyright © 2020-2023  润新知