这种1A的感觉真好

 #include <cstdio>
#include <vector>
#include <cmath>
using namespace std;
typedef long long LL; struct Point
{
LL x, y;
Point(LL x=, LL y=):x(x), y(y) {}
}; Point operator - (const Point& A, const Point& B)
{ return Point(A.x-B.x, A.y-B.y); } LL Cross(const Point& A, const Point& B)
{ return A.x*B.y-A.y*B.x; } typedef vector<Point> Polygon; LL Area(const Polygon& p)
{
LL ans = ;
int n = p.size();
for(int i = ; i < n-; i++) ans += Cross(p[i]-p[], p[i+]-p[]);
return abs(ans/);
} LL gcd(LL a, LL b) { return b == ? a : gcd(b, a%b); } LL Boundary(const Polygon& p)
{
LL ans = ;
int n = p.size();
for(int i = ; i < n-; i++)
{
LL a = abs(p[i+].x - p[i].x);
LL b = abs(p[i+].y - p[i].y);
ans += gcd(a, b);
}
ans += abs(gcd(p[n-].x-p[].x, p[n-].y-p[].y));
return ans;
} int main()
{
//freopen("in.txt", "r", stdin);
int n;
while(scanf("%d", &n) == && n)
{
Polygon poly;
Point p;
for(int i = ; i < n; i++)
{
scanf("%lld%lld", &p.x, &p.y);
poly.push_back(p);
}
LL A = Area(poly);
LL b = Boundary(poly);
printf("%lld\n", A - b/ + );
} return ;
}

代码君

假设平面上有一个顶点均为格点的单纯多边形(simple polygon)

其面积为A,边界上的格点数为b,内部格点数为i,则有恒等关系:

A = b/2 + i - 1

链接:

http://episte.math.ntu.edu.tw/articles/sm/sm_25_10_1/page4.html

从问题的抛出,从特殊情况开始猜想,然后修正,最后给出证明。写得很好。

但是没有证明里面提到的“原子三角形”面积为1/2的命题,难道这个是非常显然的吗?=_=||

维基百科:

http://en.wikipedia.org/wiki/Pick%27s_theorem

比较严格的证明,但没有上一篇通俗易懂。

http://www.cut-the-knot.org/ctk/Farey.shtmlFarey%20Series

这个证明没看,但是后面提到了Pick定理在Farey级数中的应用,留坑,以后再看。

UVa 10088 (Pick定理) Trees on My Island的更多相关文章

  1. UVa 10088 - Trees on My Island (pick定理)

    样例: 输入:123 16 39 28 49 69 98 96 55 84 43 51 3121000 10002000 10004000 20006000 10008000 30008000 800 ...

  2. LightOJ 1418 Trees on My Island (Pick定理)

    题目链接:LightOJ 1418 Problem Description I have bought an island where I want to plant trees in rows an ...

  3. HDU 3775 Chain Code ——(Pick定理)

    Pick定理运用在整点围城的面积,有以下公式:S围 = S内(线内部的整点个数)+ S线(线上整点的个数)/2 - 1.在这题上,我们可以用叉乘计算S围,题意要求的答案应该是S内+S线.那么我们进行推 ...

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

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

  5. Area(Pick定理POJ1256)

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5429   Accepted: 2436 Description ...

  6. poj 2954 Triangle(Pick定理)

    链接:http://poj.org/problem?id=2954 Triangle Time Limit: 1000MS   Memory Limit: 65536K Total Submissio ...

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

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

  8. poj1265Area(pick定理)

    链接  Pick定理是说,在一个平面直角坐标系内,如果一个多边形的顶点全都在格点上,那么这个图形的面积恰好就等于边界上经过的格点数的一半加上内部所含格点数再减一. pick定理的一些应用 题意不好懂, ...

  9. pick定理:面积=内部整数点数+边上整数点数/2-1

    //pick定理:面积=内部整数点数+边上整数点数/2-1 // POJ 2954 #include <iostream> #include <cstdio> #include ...

随机推荐

  1. MITK Tutorial

      MITK 设计来使用模块化和高度的代码重用,既能作为 pure software library或complete application framework.它的结构概览图如下: ITK:提供分 ...

  2. python re 正则表达式[转]

    01.#!/usr/bin/env python 02.# -*- coding: utf-8 -*- 03.import re 04. 05.def regex(): 06. str = 'abcd ...

  3. 双倍边距bug

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  4. zoj 3745 Salary Increasing(坑爹的细节题!)

    题目 注意题目中的,引用绝望的乐园中的进一步解释如下: 这是一道浙大月赛的题,一如既往的坑爹,好好一道水题,被搞成一道坑题!!! //注意:r(i) < l(i+1) !细节啊细节! #incl ...

  5. AJAX请求也会重新刷新整个页面?

    由于对HTML的一些内置行为不理解,所以面对今天的AJAX请求也会重新绘页面百思不得其解. 后来,请教跟伟哥同属前端组的杨成之后,才知道是由于button的默认行为导致的. 需要阻止这种标签行为,才可 ...

  6. String类的使用 Part1

    String类的属性 1:Chars属性 获取当前 String 对象中位于指定位置的 Char 对象. 2:Length属性 获取当前 String 对象中的字符数. eg:获取字符串中  字母, ...

  7. 【POJ3243】拓展BSGS(附hash版)

    上一篇博文中说道了baby step giant step的方法(简称BSGS),不过对于XY mod Z = K ,若x和z并不互质,则不能直接套用BSGS的方法了. 为什么?因为这时候不存在逆元了 ...

  8. lintcode 中等题:subSets 子集

    题目 子集 给定一个含不同整数的集合,返回其所有的子集 样例 如果 S = [1,2,3],有如下的解: [ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], ...

  9. lintcode: 爬楼梯

    题目: 爬楼梯 假设你正在爬楼梯,需要n步你才能到达顶部.但每次你只能爬一步或者两步,你能有多少种不同的方法爬到楼顶部? 样例 比如n=3,中不同的方法 返回 3 解题: 动态规划题目,同时还是有顺序 ...

  10. POJ1470 Closest Common Ancestors

    LCA问题,用了离线的tarjan算法.输入输出参考了博客http://www.cnblogs.com/rainydays/archive/2011/06/20/2085503.htmltarjan算 ...