hdu1215 The area

hdu 1215 The area

算抛物线和直线解析式,简单积分

#include <iostream>
#include<cstdio>
using namespace std;
double  p2x,p2y,p1x,p1y,p3x,p3y;
double  a,b,c,a1,b1;
double  ans;
void solve1()
{
    //求直线
    a1 = (p3y-p2y)/(p3x-p2x);
    b1 = (p2y - p2x*a1);
    //求抛物线解析式
    double  t1,t2,q1,q2,p1,p2;
    t1 = p2x*p2x - p1x*p1x;
    t2 = p1x*p1x - p3x*p3x;
    p1 = p2x-p1x;
    p2 = p1x-p3x;
    q1 = p2y-p1y;
    q2 = p1y-p3y;
    a = (q1*p2 - q2*p1)/(t1*p2-t2*p1);
    b = (q1-a*t1)/p1;
    c = p2y - (a*p2x*p2x + b*p2x);
    //求差方程解析式
    b = b - a1;
    c = c - b1;
    //求积分
    a = a/3;
    b = b/2;
    ans = (p2x*p2x*p2x*a) + (p2x*p2x*b) + (p2x*c);
    ans -=(p3x*p3x*p3x*a) + (p3x*p3x*b) + (p3x*c);
    ans = ans > 0?ans:-ans;
}
int main()
{
    int cas;
    cin  >> cas;
    while(cas --){
        cin >> p1x>>p1y>>p2x>>p2y>>p3x>>p3y;
        solve1();
        printf("%0.2f\n",ans);
    }
    return 0;
}
时间: 2024-10-11 17:54:36

hdu1215 The area的相关文章

POJ 2546 &amp; ZOJ 1597 Circular Area 两圆的面积交

Circular Area Time Limit: 2 Seconds      Memory Limit: 65536 KB Your task is to write a program, which, given two circles, calculates the area of their intersection with the accuracy of three digits after decimal point. Input In the single line of in

map area (append)

<html><body><script src="http://code.jquery.com/jquery-1.11.0.min.js"></script><!--<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>--><script >    $(function(){ 

使用area标签模仿a标签

众所周知,map标签可以给img图像标记热点区域,而area标签就是跟map标签一起使用的. 但area标签的作用可不止用来标记热点,因为它也有href属性,因此某些场景可以代替a标签进行页面跳转. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style ty

HDU1071 The area

Ignatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and a straight line. The picture below shows the area. Now given all the intersectant points shows in the picture, can you tell Ignat

25.按要求编写一个Java应用程序: (1)编写一个矩形类Rect,包含: 两个属性:矩形的宽width;矩形的高height。 两个构造方法: 1.一个带有两个参数的构造方法,用于将width和height属性初化; 2.一个不带参数的构造方法,将矩形初始化为宽和高都为10。 两个方法: 求矩形面积的方法area() 求矩形周长的方法perimeter() (2)通过继承Rect类编写一个具有

package zhongqiuzuoye; public class Rect { public double width; public double height; Rect(double width,double height) //带有两个参数的构造方法,用于将width和height属性初化; { this.width=width; this.height=height; } Rect() //不带参数的构造方法,将矩形初始化为宽和高都为10. { width=10; height=

Broadmann area (wiki)

Sources: https://en.wikipedia.org/wiki/Brodmann_area Lateral surface Medial serface Areas 3, 1 & 2 – Primary Somatosensory Cortex (frequently referred to as Areas 3, 1, 2 by convention) Area 4 – Primary Motor Cortex Area 5 – Somatosensory Association

[UVA Live 12931 Common Area]扫描线

题意:判断两个多边形是否有面积大于0的公共部分 思路:扫描线基础. #pragma comment(linker, "/STACK:10240000") #include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back #define mp make_pair #define all(a) (a).begin(), (a).end() #de

LeetCode:Rectangle Area - 矩形交叉部分的面积

1.题目名称 Rectangle Area(矩形交叉部分的面积) 2.题目地址 https://leetcode.com/problems/rectangle-area/ 3.题目内容 英文:Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as shown

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