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. iOS 用其他应用程序打开文件功能

    先摘抄一段我抄别人用的. <key>CFBundleDocumentTypes</key>    <array>        <dict>       ...

  2. codeforces round#510

    蒟蒻和以前一样还是只能做 $4$ 题, 希望有一天可以 水到 $5$ 题!! 不过也终于上了蓝了...   A. Benches Description 给出$N$个座位, 每个座位上初始有$a_i$ ...

  3. 05. pt-diskstats

    pt-diskstats --devices-regex=sda --interval=1 --iterations=3 --show-timestamps #ts device rd_s rd_av ...

  4. Servlet会话管理二(Cookie)

    Cookie是在HTTP协议下,将服务器传递给浏览器的的少量信息保存到浏览器客户端的一种技术,通过这种技术,即使在浏览器被关闭或链接中断的情况下,用户仍可以维护Cookie中的数据. Cookie是经 ...

  5. Autofs

    1. Introduction autofs is a program for automatically mounting directories on an as-needed basis. Au ...

  6. 学习selenium的过程

  7. 利用PHP脚本辅助MySQL数据库管理3-删除重复表索引

    <?php $dbi = new DbMysql; $dbi->dbh = 'mysql://root:mysql@127.0.0.1/coffeetest'; $map = array( ...

  8. 使用yarn 安装 Vue-DevTools

    1. 从 github 下载 vuejs/vue-devtools https://github.com/vuejs/vue-devtools/archive/dev.zip 2.安装yarn 及 编 ...

  9. jquery库google加载

    加载js库的时候可以加载google CDN,可以同时加载多个jquery库<script src="http://www.google.com/jsapi">< ...

  10. mysql练习题3

    USE day44; -- 1 查出所有员工的名字,薪资,格式为 -- <名字:egon> <薪资:3000> SELECT '姓名:',name,'薪资:',salary f ...