Sweety

Practice makes perfect

导航

第五届山东省ACM angry_birds_again_and_again(积分)

Posted on 2016-05-11 21:51  蓝空  阅读(123)  评论(0编辑  收藏  举报

angry_birds_again_and_again

给定曲线,给定一个点,求从曲线上某点到x轴上某点直线恰为曲线切线和曲线围成的面积。

水题,求积分做就好了,但是开始还错了,回车竟然判成WR而不是PR,第一题就卡,醉了。。。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<ctime>
#define eps 1e-6
#define MAX 100005
#define INF 0x3f3f3f3f
#define LL long long
#define pii pair<string,int>
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d%d",&x,&y)
using namespace std;
int main()
{
    double a,b,du;
    double  T,P;
    int xx,yy;
    int n;
    rd(n);
    while(n--)
    {
        rd2(xx,yy);
        T=yy,P=xx;
        scanf("%lf",&du);
        b=tan(du);
        a=b*P/(T*T-2*T*P);
        double y0=a*T*T+b*T;
        double area = 1/3.0*a*T*T*T+1/2.0*b*T*T  +   1/2.0*(P-T)*y0;
        //cout<<a<<' ' <<y0<<endl;
        printf("%.3f\n",area);
    }
    return 0;
}