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;
}
时间: 2024-10-14 23:53:53

HDU 1071 The area (数学定积分)的相关文章

hdu 1071 The area【定积分】

用顶点式\( a(x-h)^2+k=y \)解方程,转化为\(ax^2+bx+c=y \)的形式,然后对二次函数求定积分\( \frac{ax^3}{3}+\frac{bx^2}{2}+cx+C \)即可.(其实我不知道那个C是干什么用的反正这里不用加. #include<iostream> #include<cstdio> using namespace std; int T; double x1,x2,x3,y1,y2,y3,a,b,c,h,k; double f(double

hdu 1071 The area 高斯消元求二次函数+辛普森积分

构造系数矩阵,高斯消元求解二次函数,然后两点式求直线函数,带入辛普森积分法无脑AC... #include<cstdio> #include<queue> #include<algorithm> #include<cstring> #include<vector> #include<cmath> using namespace std; struct node { double x,y; }p[4]; double g[10][10]

hdu 1071 - The area(解题报告)

The area Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8715    Accepted Submission(s): 6115 Problem Description Ignatius bought a land last week, but he didn't know the area of the land becau

HDU 1071 The area ——微积分

[题目分析] 求二次函数和一次函数围成的面积. 先解方程求出一次函数和二次函数. 然后积分. 现在还是不会积分. [代码] #include <cstdio> #include <cstring> #include <cstdlib> //#include <cmath> #include <set> #include <map> #include <string> #include <algorithm> #

HDU 1071 - The area

求曲线和直线围成的面积 求表达式,求积分 1 #include <iostream> 2 using namespace std; 3 double x[4],y[4]; 4 int t; 5 double k,m;//fx1: y=kx+m 6 double a,b,c;//fx2: y=a(x-b)^2+c 7 void getfx1() 8 { 9 k=(y[3]-y[2])/(x[3]-x[2]); 10 m=y[2]-k*x[2]; 11 } 12 void getfx2() 13

HDU 4816 Bathysphere(数学)(2013 Asia Regional Changchun)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4816 Problem Description The Bathysphere is a spherical deep-sea submersible which was unpowered and lowered into the ocean on a cable, and was used to conduct a series of dives under the sea. The Bathys

HDU 1071 微积分

The area Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7611    Accepted Submission(s): 5332 Problem Description Ignatius bought a land last week, but he didn't know the area of the land becaus

HDU 4937 Lucky Number (数学,进制转换)

题目 参考自博客:http://blog.csdn.net/a601025382s/article/details/38517783 //string &replace(iterator first0, iterator last0,const_iterator first, const_iterator last); //把[first0,last0)之间的部分替换成[first,last)之间的字符串 /* 题意: 我们将3,4,5,6认为是幸运数字.给定一个十进制数n. 现在可以讲起任意转

HDU 1018 Big Number 数学题解

Problem Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of