zoukankan      html  css  js  c++  java
  • 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;
    }
     
  • 相关阅读:
    get、put、post、delete含义与区别
    中奖数据表设计方案
    mysql递归
    java Ajax跨域请求COOKIE无法带上的解决办法
    tomcat 下配置ajax 跨域 tomcat font face 跨域 java跨域
    JAVA入门教程
    解决Navicat 出错:1130-host . is not allowed to connect to this MySql server,MySQL
    Hbuilder开发app时生成ios要的mobileprovision和p12文件步骤.
    js 获取浏览器高度和宽度值(多浏览器)
    Windows netstat 查看端口、进程占用 查看进程路径
  • 原文地址:https://www.cnblogs.com/yinbiao/p/9327444.html
Copyright © 2011-2022 走看看