HDU 1071 The area 数学题

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1071


用抛物线的顶点公式y=a(x-x1)^2+y1外加另一个点x2算出a,再求出直线方程,之后求定积分。


代码如下:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std;

const int N=2011;
typedef long long LL;

int main()
{
    int i,j,T;
    double x1,x2,x3,y1,y2,y3;
    cin>>T;
    while(T--)
    {
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
        double a=(y2-y1)/((x2-x1)*(x2-x1));//求出a
        double k=(y3-y2)/(x3-x2),b=y3-k*x3;//求出k和b
        double a2=a,a1=-2*a*x1-k,a0=a*x1*x1+y1-b;//a2,a1,a0分别是x^2,x^1,x^0的系数
        double t=a2*x3*x3*x3/3+a1*x3*x3/2+a0*x3-(a2*x2*x2*x2/3+a1*x2*x2/2+a0*x2);//定积分
        printf("%.2lf\n",t);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值