【计算几何】Water Testing
Water Testing
题目描述
输入
• 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.
输出
样例输入
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的更多相关文章
- Water Testing【皮克定理,多边形面积,线段上点的数目】
Water Testing 传送门:链接 来源:UPC 9656 题目描述 You just bought a large piece of agricultural land, but you n ...
- Gym 101873G - Water Testing - [皮克定理]
题目链接:http://codeforces.com/gym/101873/problem/G 题意: 在点阵上,给出 $N$ 个点的坐标(全部都是在格点上),将它们按顺序连接可以构成一个多边形,求该 ...
- Codeforces-GYM101873 G Water Testing 皮克定理
题意: 给定一个多边形,这个多边形的点都在格点上,问你这个多边形里面包含了几个格点. 题解: 对于格点多边形有一个非常有趣的定理: 多边形的面积S,内部的格点数a和边界上的格点数b,满足如下结论: 2 ...
- 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)
A Drawing Borders 很多构造方法,下图可能是最简单的了 代码: #include<bits/stdc++.h> using namespace std; ; struct ...
- 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) Solution
A. Drawing Borders Unsolved. B. Buildings Unsolved. C. Joyride Upsolved. 题意: 在游乐园中,有n个游玩设施,有些设施之间有道路 ...
- (寒假开黑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 ...
- The German Collegiate Programming Contest 2017
B - Building 给一个m各面的多边形柱体,每一侧面有n*n个格子,现在对这些格子染色,看有多少种方式使得多面柱体无论如何旋转都不会与另一个一样. #include <bits/stdc ...
- 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\) ...
- ZOJ3238 Water Ring(计算几何)
题意:给你一个圆形和很多个矩形,然后要你求圆形的圆周有多少被矩形覆盖. 思路:比赛的时候是有思路的了,不过一直在调别的题,最后剩下30分钟肯定来不及敲.想法是这样的,要是我们可以求出每个矩形覆盖了圆周 ...
随机推荐
- vue-qr生成下载二维码
安装vue-qr npm install vue-qr --save 生成二维码实列 <vue-qr ref="Qrcode" :text="qrCodeConfi ...
- Node.js 目录操作
1.创建目录 mkdir 代码 demo1.js var fs = require('fs'); //创建目录 fs.mkdir('e:/nodeTest/dirTest',function(err) ...
- arcgis python 表属性转html
import arcpy import sys import string import os tablePath = arcpy.GetParameterAsText(0) filePath = a ...
- perl 语法速查 | 模块安装
perl -MCPAN -e shell install Bio::SeqIO 或者直接perl -MCPAN -e 'install Excel::Writer::XLSX' 用cpan装不上,编译 ...
- ASP.NET MVC传递Model到视图的多种方式之通用方式的使用
ASP.NET MVC传递Model到视图的多种方式总结——通用方式的使用 有多种方式可以将数据传递到视图,如下所示: ViewData ViewBag PartialView TempData Vi ...
- Java并发包线程池之ForkJoinPool即ForkJoin框架(二)
前言 前面介绍了ForkJoinPool相关的两个类ForkJoinTask.ForkJoinWorkerThread,现在开始了解ForkJoinPool.ForkJoinPool也是实现了Exec ...
- osg HUD 背景图片设置
#ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include<iostream> #include <osgV ...
- labelimg data
<annotation> <folder>img_data_box_1500</folder> <filename>798.jpg</filena ...
- 19 Flutter 自定义AppBar 定义顶部Tab切换 底部Tab结合顶部Tab实现类似头条页面布局(27分36秒)
Flutter AppBar自定义顶部导航按钮图标.颜色以及TabBar定义顶部Tab切换. leading:在标题前面显示的一个控件,在首页通常显示应用的logo:在其他界面通常显示为付汇按钮. t ...
- linux下使用SVN上传项目
linux下使用SVN上传项目 摘自:https://blog.csdn.net/puppet_/article/details/78259591 2017年10月17日 13:51:33 puppe ...