Water Testing

题目描述

You just bought a large piece of agricultural land, but you noticed that – according to regulations – you have to test the ground water at specific points on your property once a year. Luckily the description of these points is rather simple. The whole country has been mapped using a Cartesian Coordinate System (where (0, 0) is the location of the Greenwich Observatory). The corners of all land properties are located at integer coordinates according to this coordinate system. Test points for ground water have to be erected on every point inside a property whose coordinates are integers.

输入

The input consists of:
• one line with a single integer n (3 ≤ n ≤ 100 000), the number of corner points of your property;
• n lines each containing two integers x and y (−106 ≤ x, y ≤ 106 ), the coordinates of each corner.
The corners are ordered as they appear on the border of your property and the polygon described by the points does not intersect itself.

输出

The number of points with integer coordinates that are strictly inside your property.

样例输入

4
0 0
0 10
10 10
10 0

样例输出

81


【题解】

皮克定理模版题,大家注意,面积可能在点乘的时候是负数。

还需要开Long Long

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e6+; ll gcd(ll u,ll v){
return (v == 0ll) ? u : gcd(v,u%v);
} typedef struct point{
ll x , y ;
point() {}
point(ll a,ll b):x(a),y(b) {}
void input(){
scanf("%lld%lld",&x,&y);
}
friend point operator + ( const point &a , const point &b ){
return point(a.x + b.x , a.y + b.y );
}
friend point operator - ( const point &a , const point &b ){
return point(a.x - b.x , a.y - b.y );
} }point; point List[maxn];
ll det(const point & a , const point & b){
return a.x * b.y - a.y * b.x ;
} ll Abs( ll x ){
return (x>=?x:-x);
} ll area( point a[] ,int n)
{
ll sum = ;
a[n] = a[] ;
for(int i=; i<n; i++) sum += det(a[i+],a[i]);
return sum ;
}
ll Border_Int_Point_Num( point a[] , int n)
{
ll num = ;
a[n] = a[];
for(int i=; i<n; i++)
{
if( Abs((a[i+].x-a[i].x)) == ){
num += Abs(a[i+].y-a[i].y);
}else if( Abs((a[i+].y-a[i].y)) == ){
num += Abs(a[i+].x-a[i].x);
}else{
num += gcd(Abs(ll(a[i+].x-a[i].x)),Abs(ll(a[i+].y-a[i].y)));
}
}
return num ;
}
ll Inside_Int_Point_Num( point a[] , int n )
{
ll Area = area(a,n) ;
Area = Abs(Area);
return ( Area - Border_Int_Point_Num(a,n) ) / + ; }
//polyon S ; int n;
int main()
{
scanf("%d",&n);
//S.n = n ; for(int i=;i<n;i++)
List[i].input();
/*
sort ( List , List + n , cmp ); for(int i=n-1;i>=0;i--){
S.a[i] = List[n-i-1] ;
} for(int i=0;i<n;i++){
scanf("%lld%lld",&S.a[i].x,&S.a[i].y);
}
*/
printf("%lld\n",Inside_Int_Point_Num(List,n));
return ;
}

【计算几何】Water Testing的更多相关文章

  1. Water Testing【皮克定理,多边形面积,线段上点的数目】

    Water Testing 传送门:链接  来源:UPC 9656 题目描述 You just bought a large piece of agricultural land, but you n ...

  2. Gym 101873G - Water Testing - [皮克定理]

    题目链接:http://codeforces.com/gym/101873/problem/G 题意: 在点阵上,给出 $N$ 个点的坐标(全部都是在格点上),将它们按顺序连接可以构成一个多边形,求该 ...

  3. Codeforces-GYM101873 G Water Testing 皮克定理

    题意: 给定一个多边形,这个多边形的点都在格点上,问你这个多边形里面包含了几个格点. 题解: 对于格点多边形有一个非常有趣的定理: 多边形的面积S,内部的格点数a和边界上的格点数b,满足如下结论: 2 ...

  4. 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

    A Drawing Borders 很多构造方法,下图可能是最简单的了 代码: #include<bits/stdc++.h> using namespace std; ; struct ...

  5. 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) Solution

    A. Drawing Borders Unsolved. B. Buildings Unsolved. C. Joyride Upsolved. 题意: 在游乐园中,有n个游玩设施,有些设施之间有道路 ...

  6. (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

    layout: post title: (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) au ...

  7. The German Collegiate Programming Contest 2017

    B - Building 给一个m各面的多边形柱体,每一侧面有n*n个格子,现在对这些格子染色,看有多少种方式使得多面柱体无论如何旋转都不会与另一个一样. #include <bits/stdc ...

  8. 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)(9/11)

    $$2017-2018\ ACM-ICPC\ German\ Collegiate\ Programming\ Contest (GCPC 2017)$$ \(A.Drawing\ Borders\) ...

  9. ZOJ3238 Water Ring(计算几何)

    题意:给你一个圆形和很多个矩形,然后要你求圆形的圆周有多少被矩形覆盖. 思路:比赛的时候是有思路的了,不过一直在调别的题,最后剩下30分钟肯定来不及敲.想法是这样的,要是我们可以求出每个矩形覆盖了圆周 ...

随机推荐

  1. 探究机器码,深入研究C语言程序的机制

    用C高级编程语言写的程序,都要经过编译链接成本机可执行的程序.这个可执行程序究竟是什么呢?在Linux上,我们可以用objdump命令很方便地查看一个可执行程序的机器码.我们从一个简单的示例开始,说一 ...

  2. LeetCode 第 151 场周赛

    一.查询无效交易(LeetCode-1169) 1.1 题目描述 1.2 解题思路 根据,它和另一个城市中同名的另一笔交易相隔不超过 60 分钟(包含 60 分钟整) 得出 城市A和其他城市任何一笔交 ...

  3. Cesium中常用的一些地理数据文件 以及数据相关的东西

    KML Cesium.KmlDataSource.load CZML Cesium.CzmlDataSource.load GeoJson Cesium.GeoJsonDataSource.load ...

  4. linux物理内存与虚拟内存

    http://www.360doc.com/content/14/0123/14/14450281_347336709.shtml 1.查看内存占用情况 $ free -m -h total used ...

  5. 【源码】openresty 限流

    小结: 1.在连接环节计数,有清零环节 有3个参量 maxburst unit_delay https://github.com/openresty/lua-resty-limit-traffic/b ...

  6. 【转】nodejs接收前端formData数据

    很多时候需要利用formdata数据格式进行前后端交互. 前端代码可以是如下所示: <!DOCTYPE html> <html lang="en"> < ...

  7. 41 Flutter 仿京东商城项目签名验证 增加收货地址、显示收货地址 事件广播

    加群452892873 下载对应41课文件,运行方法,建好项目,直接替换lib目录 AddressAdd.dart import 'package:dio/dio.dart'; import 'pac ...

  8. 阶段5 3.微服务项目【学成在线】_day18 用户授权_18-微服务之间认证-需求分析

    4.1 需求分析 前边章节已经实现了用户携带身份令牌和JWT令牌访问微服务,微服务获取jwt并完成授权. 当微服务访问微服务,此时如果没有携带JWT则微服务会在授权时报错. 测试课程预览: 1.将课程 ...

  9. 123457123457#0#-----com.yimeng.TouNaoWangZhe--前拼后广--brain游戏one

    com.yimeng.TouNaoWangZhe--前拼后广--brain游戏one

  10. 123457123457#1#-----com.threeapp.circlerunner01----儿童旋转跑酷游戏

    com.threeapp.circlerunner01----儿童旋转跑酷游戏