一些项目——The area

Problem Description

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 Ignatius the
area of the land?

Note: The point P1 in the picture is the vertex of the parabola.

Input

The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.

Each test case contains three intersectant points which shows in the picture, they are given in the order of P1, P2, P3. Each point is described by two floating-point numbers X and Y(0.0<=X,Y<=1000.0).

Output

For each test case, you should output the area of the land, the result should be rounded to 2 decimal places.

Sample Input

2
5.000000 5.000000
0.000000 0.000000
10.000000 0.000000
10.000000 10.000000
1.000000 1.000000
14.000000 8.222222

Sample Output

33.33
40.69

Hint

For float may be not accurate enough, please use double instead of float.

代码

#include <iomanip>
#include <iostream>
using namespace std ;
int main ()
{
    int n ;
    cin>>n;
    double a , s ;
    double area ;
    double x1 , y1 , x2 , y2 , x3 , y3 ;
    while (n--)
    {
        cin>>x1>>y1;
        cin>>x2>>y2;
        cin>>x3>>y3;
        a = ( y3 - y1 ) / ( ( x3 - x1 ) * ( x3 - x1 ) ) ;
        s = ( ( y2 + y3 ) * ( x3 - x2 ) ) / 2 ;
        area = ( (( a*(x3-x1)*(x3-x1)*(x3-x1) ) / 3 + y1*x3 ) - (( a*(x2-x1)*(x2-x1)*(x2-x1) ) / 3 + y1*x2 ) ) - s ;
        cout<<setiosflags(ios::fixed)<<setprecision(2)<<area<<endl;
    }
    return 0 ;
}
时间: 2024-07-29 13:06:43

一些项目——The area的相关文章

Web API项目中使用Area对业务进行分类管理

在之前开发的很多Web API项目中,为了方便以及快速开发,往往把整个Web API的控制器放在基目录的Controllers目录中,但随着业务越来越复杂,这样Controllers目录中的文件就增加很快,难以管理,而且如果有不同业务模块有重复的控制器名的话,还需要尽量避免.引入Area的作用就是把控制器按照不同的业务模块进行区分,方便管理,而且控制器名称可以重名. 1.Web API项目引入Area进行分类 Area在项目中可以称之为区域,每个Area代表应用程序的不同功能模块,Area 使每

MVC3使用Area解耦项目

源代码 1.增加AreasChildRegistration类,类继承PortableAreaRegistration 2.增加引用MvcContrib 3.主项目中Area文件夹下增加Web.config文件

SharePoint 2013 使用查阅项实现联动下拉框

SharePoint列表使用中,经常会用到下拉框,而有些特殊的需求,会用到联动的下拉框,在SharePoint中默认没有这样的字段,所以如果实现,我们需要自己想办法. 这里,我们介绍如何使用JQuery+JavaScript客户端对象模型实现,下面让我简单介绍下实现的全过程. 1.创建基础列表CityList,保存的是城市名称,使用默认字段Title: 2.列表CityList的所有栏,我把Title字段的名称改为了City Name,如下图: 3.创建基础列表AreaList,用于保存所有区和

ASP.NET MVC——MVC-路由

Routing(路由) – URL url 作为广泛使用的Web用户接口,需要被重视 好的Url应该满足如下条件: URL应为获取某种资源提供信息,不一定是物理文件路径 简短易于记忆和拼写输入 可以反映出站点结构 应该是[可拆分],用户移除末尾,进而获得更高层次信息 持久.不应改变 下面两种url哪种你更喜欢呢?http://www.cnblogs.com/baka_no/1.htmlhttp://www.cnblogs.com/baka_no/1如果是后者,那服务器怎么识别呢?ASP.NET

ASP.NET MVC Area使用-将Area设置成独立项目

环境说明:Vistual Studio 2013 MVC 4.0 其实关于ASP.NET MVC Area使用的基础知识可以参考 http://www.cnblogs.com/willick/p/3331519.html 这篇软文. Global.asax 中的 Application_Start 方法里面有这样一句代码 AreaRegistration.RegisterAllAreas(); 估计: 它的作用会到当前MVC 所在的bin中动态注入继承了 AreaRegistration的类,

Asp.net MVC 4新项目中创建area的后续操作

Asp.net MVC 4新项目中创建area后,往往HomeController与area的HomeController路由发生混淆,需要手工设置一些地方避免mvc无法识别默认路由的状况. 无废话具体步骤: 1. 检查早Global.asax和\App_Start\RouteConfig.cs中是否已经自动添加了AreaRegistration.RegisterAllAreas();如不存在,进入第2步,否则第3步 2. 在\App_Start\RouteConfig.cs中,添加AreaRe

第三周项目3-程序的多文件组织

利用多文件组织,重新实现项目2.其中,整个项目包括3个文件: 主文件: main.cpp,用于定义main()函数 头文件: triangle.h,头文件,声明类,定义内置成员函数 类定义文件: triangle.cpp,用于定义类Triangle中其他成员函数 注意,将3个set函数和3个get函数设计成内置成员函数,其他函数不作为内置函数. main.cpp /* * Copyright (c) 2015,烟台大学计算机学院 * All right reserved. * 作者:邵帅 * 文

layUI独立组件layer-laydate-laypage项目实践用法

layUI官网:http://www.layui.com/ 有以下四个独立组件(可单独使用): 弹出层组件layer链接:http://layer.layui.com/ 日期组件laydate链接:https://www.layui.com/laydate/ 分页组件laypage链接:https://www.layui.com/laypage/ 轻量的JavaScript模板引擎laytpl链接:https://www.layui.com/laytpl/(暂未使用) 项目中实践用法汇总 项目技

【无私分享:ASP.NET CORE 项目实战(第九章)】创建区域Areas,添加TagHelper

目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 在Asp.net Core VS2015中,我们发现还有很多不太简便的地方,比如右击添加视图,转到试图页等功能图不见了,虽然我们可以通过工具栏的自定义命令,把这两个右击菜单添加上,但是貌似是灰色的不能用. 其实,这样也好,通过手动创建,更让我们深刻的理解MVC以及路由之间的关系,很多人认为底层的东西是高大上的,比如一提到汇编,很多人感觉牛的不行不行的,其实术业有专攻,做程序的感觉搞核电的很牛,搞核电的同样也感觉做程序的很牛