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. GitHub上README.md教程 详情介绍 (修改图片连接地址错误)

    最近对它的README.md文件颇为感兴趣.便写下这贴,帮助更多的还不会编写README文件的同学们. README文件后缀名为md.md是markdown的缩写,markdown是一种编辑博客的语言 ...

  2. windows下Git的使用教程(github)

    这表文章主要是用命令操作: 使用可视化软件操作:https://www.cnblogs.com/mswyf/p/9261859.html 一.下载安装Git Bash 下载安装:https://www ...

  3. Oracle VM VirtualBox如何设置网络地址转换NAT

    使用VirtualBox 安装好服务器后,需要设置网络,如果有IP, 则可以直接连接物理网络了, 如果没有,则可以直接使用NAT网络.设置方便快速. 先将虚拟机中的网络设置为自动获取,然后点击Virt ...

  4. tp5安装验证码

  5. 【SpringAop】【统一日志处理】注解方式理解以及使用

    [注意:本次代码的demo会存在百度网盘,由于公司的保密,禁止上传,所以仅本人可见] 目前公司在做数据资产项目,数据质量部分使用到了springaop做统一日志处理,以前对这块有了解,有点模糊不清,今 ...

  6. Java中的逆变与协变 很直接不饶弯的讲出来了

    ```java 协变 extends只能new 辈分比自己低的家伙 List<? extends Number> list001 = new ArrayList<Integer> ...

  7. Linux修改/etc/profile配置错误command is not found自救方法

    export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

  8. centos下安装配置jetty

    下载jdk-8u144-linux-x64.tar.gz # tar -zxvf jdk-8u144-linux-x64.tar.gz # mv jdk1.8.0_144 /usr/java/ # u ...

  9. spring学习 十四 注解AOP 通知传递参数

    我们在对切点进行增强时,不建议对切点进行任何修改,因此不加以使用@PointCut注解打在切点上,尽量只在Advice上打注解(Before,After等),如果要在通知中接受切点的参数,可以使用Jo ...

  10. 一波水题 MZOJ 1035: 贝克汉姆

    #include <bits/stdc++.h> using namespace std; ; int n,m; int v[N],w[N],f[N]; int main() { scan ...