//pick定理:面积=内部整数点数+边上整数点数/2-1
// POJ 2954 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define LL long long
typedef pair<int,int> pii;
const double inf = 0x3f3f3f3f;
const LL MOD =100000000LL;
const int N =;
#define clc(a,b) memset(a,b,sizeof(a))
const double eps = 1e-;
void fre() {freopen("in.txt","r",stdin);}
void freout() {freopen("out.txt","w",stdout);}
inline int read() {int x=,f=;char ch=getchar();while(ch>''||ch<'') {if(ch=='-') f=-; ch=getchar();}while(ch>=''&&ch<='') {x=x*+ch-'';ch=getchar();}return x*f;} int sgn(double x){
if(fabs(x) < eps)return ;
if(x < )return -;
else return ;
} struct Point{
int x,y;
Point(){}
Point(int _x,int _y){
x = _x;y = _y;
}
Point operator -(const Point &b)const{
return Point(x - b.x,y - b.y);
}
int operator ^(const Point &b)const{
return x*b.y - y*b.x;
}
int operator *(const Point &b)const{
return x*b.x + y*b.y;
}
friend bool operator<(const Point &a,const Point &b){
if(fabs(a.y-b.y)<eps) return a.x<b.x;
return a.y<b.y;
}
}; int area(Point a,Point b,Point c){
return fabs((a-c)^(b-c));
}
//求多边形边上整点的数目,顶点必须为整数点
int fun(Point a,Point b){
int x,y;
x=abs(a.x-b.x);
y=abs(a.y-b.y);
return __gcd(x,y);
}
int main(){
// fre();
int x1,y1,x2,y2,x3,y3;
while(~scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3),x1||x2||x3||y1||y2||y3){
int ans=area(Point(x1,y1),Point(x2,y2),Point(x3,y3));
int cnt=;
Point a,b,c;
a=Point(x1,y1);
b=Point(x2,y2);
c=Point(x3,y3);
cnt+=fun(a,b);
cnt+=fun(a,c);
cnt+=fun(b,c);
printf("%d\n",(ans-cnt)/+);
}
return ;
}

pick定理:面积=内部整数点数+边上整数点数/2-1的更多相关文章

  1. poj 1265 Area【计算几何:叉积计算多边形面积+pick定理计算多边形内点数+计算多边形边上点数】

    题目:http://poj.org/problem?id=1265 Sample Input 2 4 1 0 0 1 -1 0 0 -1 7 5 0 1 3 -2 2 -1 0 0 -3 -3 1 0 ...

  2. Area - POJ 1265(pick定理求格点数+求多边形面积)

    题目大意:以原点为起点然后每次增加一个x,y的值,求出来最后在多边形边上的点有多少个,内部的点有多少个,多边形的面积是多少. 分析: 1.以格子点为顶点的线段,覆盖的点的个数为GCD(dx,dy),其 ...

  3. POJ1265——Area(Pick定理+多边形面积)

    Area DescriptionBeing well known for its highly innovative products, Merck would definitely be a goo ...

  4. POJ 1265 Area (Pick定理 & 多边形面积)

    题目链接:POJ 1265 Problem Description Being well known for its highly innovative products, Merck would d ...

  5. 格点多边形面积公式(Pick定理)的一个形象解释(转)

    Pick定理:如果一个简单多边形(以下称为“多边形”)的每个顶点都是直角坐标平面上的格点,则称该多边形为格点多边形.若一个面积为S的格点多边形,其边界上有a个格点,内部有b个格点,则S=a/2+b-1 ...

  6. poj 1265 Area (Pick定理+求面积)

    链接:http://poj.org/problem?id=1265 Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions:  ...

  7. POJ 1265 Area POJ 2954 Triangle Pick定理

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5227   Accepted: 2342 Description ...

  8. poj 1265&&poj 2954(Pick定理)

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5811   Accepted: 2589 Description ...

  9. 【POJ】2954 Triangle(pick定理)

    http://poj.org/problem?id=2954 表示我交了20+次... 为什么呢?因为多组数据我是这样判断的:da=sum{a[i].x+a[i].y},然后!da就表示没有数据了QA ...

随机推荐

  1. SPOJ 227 Ordering the Soldiers 线段树 / 树状数组

    题意:设原数组为a[i],pos[i]代表第 i 个位置之前有多少个数比a[i]大,求原数组a[i]. 这个题意是看了别人的题解才明白,我自己没读出来…… 方法:假设我们从左往右放,因为后面的数还有可 ...

  2. arcgis javascript dojo

    一.为什么说ArcGIS API for JavaScript是构建于Dojo之上的? 1. 编写ArcGIS API for JavaScript的ESRI开发者使用Dojo来简化他们的开发过程,同 ...

  3. Android 代码监控apk安装,卸载,替换

    public class GetBroadcast extends BroadcastReceiver { private static GetBroadcast mReceiver = new Ge ...

  4. ccnu-线段树-单点更新3-C

    C - 单点更新3 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Des ...

  5. php关于static关键字

    静态属性与方法可以在不实例化类的情况下调用,直接使用类名::方法名的方式进行调用.静态属性不允许对象使用->操作符调用.静态方法中,$this伪变量不允许使用.可以使用self,parent,s ...

  6. STL笔记(5)条款49:学习破解有关STL的编译器诊断信息

    STL笔记(5)条款49:学习破解有关STL的编译器诊断信息 条款49:学习破解有关STL的编译器诊断信息 用一个特定的大小定义一个vector是完全合法的, vector<int> v( ...

  7. tuning 02 Diagnostic and Tuning Tools

    statspack 是一个很重要的工具, 这是我们重点要知道的在这章 每天一上班就要看一下 alert log 文件, 可以通过/ORA找, 这是vi的知识,所有的ORACLE错误都是以ORA开头的 ...

  8. 【温故知新】c#异步编程模型(APM)--使用委托进行异步编程

    当我们用到C#类许多耗时的函数XXX时,总会存在同名的类似BeginXXX,EndXXX这样的函数. 例如Stream抽象类的Read函数就有 public abstract int Read(byt ...

  9. 【笨嘴拙舌WINDOWS】SetCapture和ReleaseCapture

    光电鼠标器是通过红外线或激光检测鼠标器的位移,将位移信号转换为电脉冲信号,再通过程序的处理和转换来控制屏幕上的光标箭头的移动的一种硬件设备. 换句话说,鼠标无时无刻不在监视着人类的活动,当人类用意识去 ...

  10. 【第二篇】.NET用NPOI读取Excel表格并在页面预览

    博主用的是npoi2.0.1,支持.xls也支持.xlsx 直接上代码吧. <table class="table table-bordered table-striped" ...