Pick公式:平面上以格子点为顶点的简单多边形的面积=边上的点数/2+内部的点数+1。

代码如下:

----------------------------------------------------------------------------------------------------------------------------

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std; const int MAXN = ;
const double EPS = 1e-; struct point
{
int x, y;
}p[MAXN]; int GCD(int m, int n)
{
if(!m || !n)
return m+n;
return GCD(n, m%n);
} int main()
{
while()
{
int ok=; for(int i=; i<; i++)
{
scanf("%d%d", &p[i].x, &p[i].y);
if(p[i].x || p[i].y)
ok = ;
} if(!ok)break;
p[] = p[]; int cnt=, area=; for(int i=; i<; i++)
{
cnt += GCD(abs(p[i].x-p[i+].x), abs(p[i].y-p[i+].y));
area += p[i].x*p[i+].y - p[i].y*p[i+].x;
}
if(area < )area = -area; printf("%d\n", (area-cnt)/+);
} return ;
}

Triangle - POJ 2954(求三角形内的格子点的个数)的更多相关文章

  1. POJ 1265 Area POJ 2954 Triangle Pick定理

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

  2. poj 2954 Triangle 三角形内的整点数

    poj 2954 Triangle 题意 给出一个三角形的三个点,问三角形内部有多少个整点. 解法 pick's law 一个多边形如果每个顶点都由整点构成,该多边形的面积为\(S\),该多边形边上的 ...

  3. UVa 11437:Triangle Fun(计算几何综合应用,求直线交点,向量运算,求三角形面积)

    Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see ...

  4. poj 1090:The Circumference of the Circle(计算几何,求三角形外心)

    The Circumference of the Circle Time Limit: 2 Seconds      Memory Limit: 65536 KB To calculate the c ...

  5. hdu 2105:The Center of Gravity(计算几何,求三角形重心)

    The Center of Gravity Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

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

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

  7. TZOJ 2519 Regetni(N个点求三角形面积为整数总数)

    描述 Background Hello Earthling. We're from the planet Regetni and need your help to make lots of mone ...

  8. HDU 2036 叉乘求三角形面积

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s) ...

  9. hrbustoj 1142:围困(计算几何基础题,判断点是否在三角形内)

    围困 Time Limit: 1000 MS     Memory Limit: 65536 K Total Submit: 360(138 users) Total Accepted: 157(12 ...

随机推荐

  1. wap开发笔记之幻灯片

    最近在进行wap站研究,发现网上成熟的wap幻灯片都很难找到,在此贴出一个iphone的幻灯效果,希望对wap站开发的人有些帮助. 点此下载

  2. PL/SQL学习(四)存储过程和函数

    原文参考:http://plsql-tutorial.com/ PL/SQL存储过程 存储过程相当于一个有名字的PL/SQL块,经过第一次编译后再次调用时不需要再次编译 创建格式: CREATE [O ...

  3. php练习7——类的运用(四则运算or面积计算[javascript小技巧——根据需求显示不同界面])

    要求:请编写一个类,该类可以进行四则运算,也可以进行矩形面积计算 1.程序 viewCount.html  Count.class.php      printCount.php 2.结果      ...

  4. struts2整合jfreechart

    需要的包: struts2-jfreechart-plugin-2.2.1.1.jar jfreechart-1.0.13.jar jcommon-1.0.17.jar 前台jsp页面中可以使用ifr ...

  5. Windows 8 系统完全上手指南 - 非常详尽的 Win8 系统入门学习手册与使用技巧专题教程!

    每次当有新版本的操作系统发布的时候,市面上总会冒出各种从入门到精通类的学习书籍,这次最新的 Windows 8 也不例外!不过,今天给大家送上免费的大礼——<Windows 8 完全上手指南&g ...

  6. E8.Net 工作流二次开发架构平台

    一.          产品简介 E8.Net工作流开发架构是基于微软.Net技术架构的工作流中间件产品,是国内商业流程管理(BPM)领域在.Net平台上的领先产品,是快速搭建流程管理解决方案的二次开 ...

  7. 贴板子系列_1-exgcd

    exgcd ll exgcd(ll a,ll b,ll &x,ll &y) { ) { x=;y=;return a; } ll r=exgcd(b,a%b,x,y); ll t=x; ...

  8. avalon中require的实现

    var plugins = { loader: function(builtin) { window.define = builtin ? innerRequire.define : otherDef ...

  9. bzoj 3328: PYXFIB 数论

    3328: PYXFIB Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 130  Solved: 41[Submit][Status][Discuss ...

  10. bzoj 2401: 陶陶的难题I 数论

    2401: 陶陶的难题I Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 89  Solved: 24[Submit][Status] Descript ...