• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
dwtfukgv
博客园    首页    新随笔    联系   管理    订阅  订阅
HDU 1071 The area (数学定积分)

题意:求阴影部分面积。

析:没什么可说的,就是一个普通的定积分。

代码如下:

#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    int T;    cin >> T;
    double x0, y0, x1, y1, x2, y2, k, b, a, c, h, s;
    while(T--){
        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("%.2lf\n", s);
    }
    return 0;
}

 

posted on 2016-06-21 20:10  dwtfukgv  阅读(283)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3