山东省第五届ACM大学生程序设计竞赛 angry_birds_again_and_again 求积分

angry_birds_again_and_again

Time Limit: 2000MS Memory limit: 65536K

题目描述

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)

输入

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 < α <  ) .

输出

One line for each case specifying the distance rounded to three digits.

示例输入

1
2 1 1.0

示例输出

0.692

提示

 

来源

2014年山东省第五届ACM大学生程序设计竞赛

示例程序


求抛物线的方程即可

ACcode:

#include <map>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#define maxn 100
using namespace std;
int main(){
    int t;
    double du,px,tx,ty,l,a,b,ans;
    scanf("%d",&t);
    while(t--){
        scanf("%lf%lf%lf",&px,&tx,&du);
        l=px-tx;
        b=tan(du);
        a=(-b*tx-b*l)/(2*tx*l+tx*tx);
        ty=a*tx*tx+b*tx;
        ans=a*tx*tx*tx/3+b*tx*tx/2+l*ty/2;
        printf("%.3lf\n",ans);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值