第五届省赛题解——A angry_birds_again_and_again(求二次函数表达式+不定积分)

A - angry_birds_again_and_again

Description
The problems called “Angry Birds” and “Angry Birds Again and Again” has been solved by many teams in the series of contest in 2011 Multi-University Training Contest.

This time we focus on the yellow bird called Chuck. Chuck can pick up speed and distance when tapped.

You can assume that before tapped, Chuck flies along the parabola. When tapped, it changes to fly along the tangent line. The Chuck starts at the coordinates (0, 0). Now you are given the coordinates of the pig (Px, 0), the x-coordinate of the tapping position (Tx) and the initial flying angle of Chuck (α).
这里写图片描述
∠AOx = α
Please calculate the area surrounded by Chuck’s path and the ground.(The area surrounded by the solid line O-Tapping position-Pig-O)
Input
The first line contains only one integer T (T is about 1000) indicates the number of test cases. For each case there are two integers, px tx, and a float number α.(0 < Tx ≤ Px ≤ 1000, 0 < α < 这里写图片描述) .
Output
One line for each case specifying the distance rounded to three digits.
Sample Input
1
2  1  1.0
Sample Output
0.692
题型:
数学
题意:
给你一个经过(0,0)点开口向下的一个二次曲线 ,再给出x轴上的点tx,px,角∠AOx,问你在tx点二次曲线,二次曲线的切线和x轴正半轴围成的曲线的面积。
题解:
先求出二次函数表达式,再求不定积分。
求在二次曲线tx处的斜率:
利用RT三角形TPD(设从TX点做垂直与x轴正半轴的直线与二次曲线的交点为D)
绝对值 tan(角DPT)=DT/PT;(注意这里的斜率是负的所以加绝对值) 推出来 -(-2*a*tx+b)=(-a*tx*tx+b*tx)/(px-tx);
即,
a=(b*tx+b*(px-tx))/(tx*tx+2*tx*(px-tx))
(因为要与X轴围城封闭图形,所以tx一定在二次曲线的右半部分,故在tx处的斜率一定为负)

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

int main()
{
    int T;
    scanf("%d",&T);
    double tx,px,rad;
    while (T--)
    {
        scanf("%lf %lf %lf",&px,&tx,&rad);
        //设二次函数表达式为y=-a*x*x+b*x
        double b=tan(rad);//由导数可知,在(0,0)点的斜率值与b相等
        double a=(b*tx+b*(px-tx))/(tx*tx+2*tx*(px-tx));//在tx处的斜率等式求a
        double y=-a*tx*tx+b*tx;//在tx的纵坐标
        double ans1=-(1.0/3.0)*tx*tx*tx*a+b*0.5*tx*tx;//二次函数0到tx的不定积分
        double ans2=y*(px-tx)*0.5;//tx到px的面积
        printf("%0.3lf\n",ans1+ans2);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值