zoukankan      html  css  js  c++  java
  • HDU 1071 The area 求定积分

    The area

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


    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
     
    /*
    题意:求定积分
    	知道三个点了 就可以求出直线和抛物线的方程 
    用抛物线的顶点公式y=a(x-x1)^2+y1外加另一个点x2算出a,再求出直线方程,之后求定积分
    */
    
    //代码一:———WA 不知道哪错了 就是交不上
    #include<stdio.h>
    double x1,x2,x3,y,y2,y3;  //不能定义y1,系统内部好像占用了,y1用y代替了。
    
    double fun(double x)
    {
    	return (y2-y)*(x-x1)*(x-x1)*(x-x1)/(3*(x2-x1)*(x2-x1))-(y3-y2)*x*x/(2*(x3-x2))+x*(y-y2+(y3-y2)/(x3-x2));
    }
    
    int main()
    {
    	int T;
    	scanf("%d",&T);
    	while(T--)
    	{
    		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y,&x2,&y2,&x3,&y3);
    		printf("%.2lf%\n",fun(x3)-fun(x2));
    	}
    	return 0;
    }
    
    //不想浪费时间了 ,copy代码AC:
    
    #include<stdio.h>
    int main()
    {
        int n,i;
        double x0,y0,x1,y1,x2,y2,k,b,a,c,h,s;
        scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
            scanf("%lf%lf%lf%lf%lf%lf",&x0,&y0,&x1,&y1,&x2,&y2);
            k=(y2-y1)/(x2-x1);
            b=y1-k*x1;
            h=x0;
            c=y0;
            a=(y1-c)/((x1-h)*(x1-h));
            s=(a*x2*x2*x2/3-(2*a*h+k)*x2*x2/2+(a*h*h+c-b)*x2)-(a*x1*x1*x1/3-(2*a*h+k)*x1*x1/2+(a*h*h+c-b)*x1);
            printf("%.2f\n",s);
        }
        return 0;
    }
    

      

    功不成,身已退
  • 相关阅读:
    ubuntu后台运行命令
    jquery获取焦点位于的元素
    thymeleaf 处理模板为字符串
    以字符串形式获取excel单元格中的内容
    ajax 上传文件
    springboot logback
    javaService
    Assistant For Chess Cards
    E生活
    易兼职-找工作兼职平台
  • 原文地址:https://www.cnblogs.com/dongsheng/p/2684031.html
Copyright © 2011-2022 走看看