My kid's school cleared a large field on their property recently to convert it into a playing area.  The field is polygonal.  The school administration decided to separate the field into two areas by building a straight picket fence between the area for the older kids and the area for the younger kids.  The fence would go between two non-adjacent vertices of the polygonal field, and given the shape of the field, all such possible fences would lie strictly and entirely within the field.
Naturally,
the smaller of the two areas would go to the younger kids.  So can you
help the school determine what the area of the smaller play-area would
be for different fence positions?
 
INPUT
The
first line contains 2 numbers N denoting the number of points in the
convex polygon and Q denoting the number of possible locations of
straight line fences.
The next N lines contain 2 integers each. The
ith line contains the integers xi yi denoting the coordinates of the ith
point of the polygon. The points are given in clockwise order.
The next Q lines contain 2 integers a b denoting that a straight line fence is to be drawn connecting a and b.
 
OUTPUT
Output
Q lines one corresponding to each query. For each query, output the
area of the smaller region for the corresponding query truncated to 1
decimal place. Always have 1 digit after the decimal place, so if the
answer is 1, output it as 1.0 instead.
 
CONSTRAINTS
4 <= N <= 50000
1 <= Q <= 50000
-20,000,000 <= x,y <= 20,000,000
0 <= a < b-1
b < N
 
SAMPLE INPUT
4 2
0 0
0 1
1 2
1 0
1 3
0 2
 
SAMPLE OUTPUT
0.5
0.5
 
EXPLANATION
The polygon is given by the points (0,0) (0,1) (1,2) (1,0).  
In
the first query, we join the points (0,1) and (1,0) which leads to the 2
areas given by (0,0) (0,1) (1,0) and (0,1) (1,2) (1,0). The first
triangle has an area of 0.5 and the second triangle has an area of 1.
The minimum of these 2 is 0.5.
In the second query, we join the
points (0,0) and (1,2) which leads to the 2 areas given by (0,0) (0,1)
(1,2) and (0,0) (1,2) (1,0). The first triangle has an area of 0.5 and
the second triangle has an area of 1. The minimum of these 2 is 0.5.

题意 :求被两点分割的凸包面积的较小值    题意已经给出顺时针啦

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm> using namespace std; #define N 50005 struct Point
{
double x, y;
void read()
{
scanf("%lf%lf",&x,&y);
} } p[N]; double area(Point p0, Point p1, Point p2)
{
return fabs((p1.x-p0.x)*(p2.y-p0.y)*1.0-(p1.y-p0.y)*(p2.x-p0.x)*1.0)/2.0;
} int main()
{
double pol[N], res;
int n, q, a, b;
scanf("%d %d",&n, &q);
for(int i = ; i < n; i++)
{
p[i].read();
pol[i] = ;
} for(int i = ; i < n; i++)
pol[i] = pol[i-] + area(p[],p[i-],p[i]);
//for(int i=1;i<n;i++)
//cout<<pol[i]<<"~~~~~~~~~~~"<<endl; // printf("%.1lf\n", pol[n-1]); for(int i = ; i < q; i++)
{
scanf("%d %d",&a, &b);
//cout<<area(p[0],p[a],p[b])<<"~~~~~~~~~~"<<endl;
if(a == )
{
res = min(pol[b],pol[n-] - pol[b]);
}
else
{
res = pol[b] - pol[a] - area(p[], p[a], p[b]);
res = min(res, pol[n-] - res);
}
printf("%.1lf\n",res);
} return ;
}

A - Playground的更多相关文章

  1. 窥探Swift编程之在Playground上尽情的玩耍

    自从苹果公司发布Swift的时候,Xcode上又多了一样新的东西---"Playground".Playground就像操场一样,可以供我们在代码的世界里尽情的玩耍,在本篇博客中就 ...

  2. 自制工具:迅速打开一个Node 环境的Playground

    需求 经常有这种情况,写代码的时候需要实验种想法,亟需一种playground 环境来玩耍.如果是前端的话可以打开chrome 的控制台,但是如果是Node 的话就比较麻烦了.我要打开我的存放试验代码 ...

  3. Particle Playground 3.03 - 粒子特效王者

    <ignore_js_op> <ignore_js_op> <ignore_js_op> <ignore_js_op> <ignore_js_op ...

  4. Swift开发第三篇——Playground

    本篇分为两部分: 一.Playground的延时运行 二.Playground的可视化 一.Playground的延时运行 Playground 就是提供一个可以即时编译的类似 REPL 的环境,他为 ...

  5. TensorFlow Playground

    A Neural Network Playground Understanding neural networks with TensorFlow Playground 机器之心翻译

  6. swift开发:试玩 Apple 站点的 playground

    https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_ ...

  7. 使用Playground编写第一个Swift程序

    从控制台输出“HelloWorld”是我学习C语言的第一步,也是我人生中非常重要的一步.多年后的今天,我仍希望以HelloWorld作为第一步,与大家共同开启一个神奇.瑰丽的世界——Swift编程. ...

  8. 0、IOS8:Xcode6 playground

    一.Playground介绍 Playground是Xcode6中自带的Swift代码开发环境.俗话说“功欲善其事,必先利其器”.以前在Xcode5中编写脚本代码,例如编写JS,其编写过程很痛苦,Xc ...

  9. Swift 提示 error running playground...

    创建playground之后,我们将得到一个错误提示,Error running playground: Failed to prepare for communication with playgr ...

  10. Swift开发学习(两):Playground

    Swift开发学习:Playground 大约 对于软件用户.游戏玩家,我一直提倡用户体验.也是用户,是各种开发工具的使用者.也会喜欢用户体验做得好的工具软件.这次苹果想开发人员所想,提供了一个能够玩 ...

随机推荐

  1. UIDataPicker 时间选择器

    自用时间选择器 @interface ViewController () { UILabel *cityLabel; UIDatePicker *datePicker; } //@property(n ...

  2. There are stopped jobs

    问题背景 系统:ubuntu,当输入exit退出shell时,出现There are stopped jobs 无法退出shell 解决办法 找到这个stopped job然后终止它 jobs 或者 ...

  3. PhpStorm 不停地 updating indices

    问题描述: 环境:PhpStorm 框架: Laravel 5.0, php artisan make:test bar.foo 之后,PhpStorm 一直不停地 Updating indices ...

  4. Aspose.Words给word文档加水印

    需求:在一些重要的Word文档需要打印时,添加水印以明出处. 方案:使用Aspose组件给word文档 代码:干货如下 /// <summary> /// Inserts a waterm ...

  5. android 使用UDP发送数据 DatagramSocket 创建对象为null

    DatagramSocket socket=null; try { socket = new DatagramSocket();  //这里创建对象为空 } catch (SocketExceptio ...

  6. JDK8集合类源码解析 - HashSet

    HashSet 特点:不允许放入重复元素 查看源码,发现HashSet是基于HashMap来实现的,对HashMap做了一次“封装”. private transient HashMap<E,O ...

  7. AX_Args

    Args args; FormRun formRun; ; args = new Args(); args.name(formstr(FormName)); args.caller(); args.r ...

  8. Java环境编写

    首先安装jdk,本系统中jdk安装在D:\jdk:jre安装在D:\Jre: 然后开始配置环境变量: JAVA_HOME:D:\jdk; JRE_HOME:D:\jre; CLASSPATH:.;%J ...

  9. hadoop web管理界面不能打开问题

    centos 7 安装好hadoop的,hadoop和yarn都正常启动,但是yarn的web界面(8088),hdfs的web界面(50070)都不能打开,防火墙是处于关闭状态. 修改默认启动级别, ...

  10. 数学小知识点整理(TBC)

    文章目录 前言 素数与同余 线性筛部分 素数 线性递推逆元 指数循环节降幂 当求逆元时模数与求逆元的数有可能不互质时的处理方法 一个神奇的结论 拓展欧拉定理 杂乱的一些性质/技巧 二进制枚举子集 异或 ...