//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. allegro使用汇总 [转贴]

    1.如何在allegro中取消花焊盘(十字焊盘) set up->design parameter ->shape->edit global dynamic shape parame ...

  2. Enable test automation in Testlink

    Enabling Test Automation in Testlink   Step 1: Change config settings in testlink config file Edit c ...

  3. C# 类的访问修改符

    C#共有五种修饰符:public.private.protected.internal.protected internal. ◆public:公有,对所有类可见,不受任何限制 ◆protected: ...

  4. PS太大GIMP可用

    图片处理中Photoshop用的非常多,但是该软件过于臃肿,使用起来也非常复杂,对于一般性的图片处理,有没有其他可以选择的工具呢? GIMP是GNU Image Manipulation Progra ...

  5. o4.数组指针和指针数组的区别

    ------- android培训.iOS培训.期待与您交流! ---------- 我们看一下数组指针和指针数组: 数组指针(也称行指针)定义 int (*p)[n];()优先级高,首先说明p是一个 ...

  6. mongodb用户授权

    1)登录admin 数据库,admin是隐藏的数据库,为mongodb的超级管理员数据表mongo admin新建用户db.createUser({'user':'test','pwd':'12345 ...

  7. LA 3516 Exploring Pyramids (记忆化搜索)

    题意 给定一个DFS序列,问能有多少树与之对应. 思路 设输入序列为S,dp(i, j)为子序列Si, Si+1, --, Sj对应的树的个数,则边界条件为d(i, i) = 1,且Si != Sj时 ...

  8. android studio 加载第三方类库

    以引入Xutil包为例 1. 将Xutil包导入到module的libs目录下 2. File->project structure 还有一种方法是在libs目录下右键点击Add as libr ...

  9. 【英语】Bingo口语笔记(77) - 临时改变计划的表达

  10. mysql 错误代码汇总

    1005:创建表失败1006:创建数据库失败1007:数据库已存在,创建数据库失败1008:数据库不存在,删除数据库失败1009:不能删除数据库文件导致删除数据库失败1010:不能删除数据目录导致删除 ...