POJ 2954 Triangle (pick 定理)】的更多相关文章

Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5227   Accepted: 2342 Description Being well known for its highly innovative products, Merck would definitely be a good target for industrial espionage. To protect its brand-new resear…
题目大意:给出三个点的坐标,问在这三个点坐标里面的整数坐标点有多少个(不包含边上的) 匹克定理:I = (A-E) / 2 + 1; A: 表示多边形面积 I : 表示多边形内部的点的个数 E: 表示在多边形上的点的个数 // Time 0ms; Memory 164K #include<iostream> #include<cstdio> #include<cmath> using namespace std; typedef struct point { int x…
poj 2954 Triangle 题意 给出一个三角形的三个点,问三角形内部有多少个整点. 解法 pick's law 一个多边形如果每个顶点都由整点构成,该多边形的面积为\(S\),该多边形边上的整点为\(L\),内部的整点为\(N\),则有: $ N + L/2 - 1 = S $ 而对于两个点\(A(x_1,y_1)\)与\(B(x_2,y_2)\),其边内部的整点数为:(不包含端点) $ gcd ( abs(x_1 - x_2) , abs(y_1 - y_2) ) - 1 $ 代码如…
链接:http://poj.org/problem?id=2954 Triangle Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5043   Accepted: 2164 Description A lattice point is an ordered pair (x, y) where x and y are both integers. Given the coordinates of the vertices…
链接:http://poj.org/problem?id=1265 Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4969   Accepted: 2231 Description Being well known for its highly innovative products, Merck would definitely be a good target for industrial espionag…
题目链接:POJ 1265 Problem Description Being well known for its highly innovative products, Merck would definitely be a good target for industrial espionage. To protect its brand-new research and development facility the company has installed the latest s…
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4373 Accepted: 1983 Description Being well known for its highly innovative products, Merck would definitely be a good target for industrial espionage. To protect its brand-new research a…
题意: 给出机器人移动的向量, 计算包围区域的内部整点, 边上整点, 面积. 思路: 面积是用三角剖分, 边上整点与GCD有关, 内部整点套用Pick定理. S = I + E / 2 - 1 I 为内整点数, E为边界整点数, S为面积. Separate the three numbers by two single blanks.....好吧, 理解成中间空两格PE一次> < #include <cstdio> #include <cstring> #includ…
题目:http://poj.org/problem?id=1265 题意:已知机器人行走步数及每一步的坐标   变化量 ,求机器人所走路径围成的多边形的面积.多边形边上和内部的点的数量. 思路:1.以格子点为顶点的线段,覆盖的点的个数为GCD(dx,dy),其中,dxdy分别为线段横向占的点数和纵向占的点数.如果dx或dy为0,则覆盖的点数为dy或dx. 2.Pick公式:平面上以格子点为顶点的简单多边形,如果边上的点数为on,内部的点数为in,则它的面积为A=on/2+in-1. 3.任意一个…
题目大意:以原点为起点然后每次增加一个x,y的值,求出来最后在多边形边上的点有多少个,内部的点有多少个,多边形的面积是多少. 分析: 1.以格子点为顶点的线段,覆盖的点的个数为GCD(dx,dy),其中,dxdy分别为线段横向占的点数和纵向占的点数.如果dx或dy为0,则覆盖的点数为dy或dx.2.Pick公式:平面上以格子点为顶点的简单多边形的面积=边上的点数/2+内部的点数+1.3.任意一个多边形的面积等于按顺序求相邻两个点与原点组成的向量的叉积之和. 代码如下: -------------…