POJ 2954 Triangle (pick 定理)
题目大意:给出三个点的坐标,问在这三个点坐标里面的整数坐标点有多少个(不包含边上的)
匹克定理: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,y;
point(int xx=0,int yy=0):x(xx),y(yy){}
}vector; point a,b,c;
vector u,v,w; vector operator - (point p,point q)
{
return vector(p.x-q.x,p.y-q.y);
}
int cross(vector p,vector q)
{
return p.x*q.y-p.y*q.x;
}
int gcd(int x,int y)
{
static int t;
for(;t=y;y=x%y,x=t);
return x;
}
int main()
{
int i,A,I,E;
while(scanf("%d%d%d%d%d%d",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)!=EOF && (a.x || a.y || b.x || b.y || c.x || c.y))
{
u=a-b;
v=b-c;
w=c-a;
A=abs(cross(u,v));
E=abs(gcd(u.x,u.y))+abs(gcd(v.x,v.y))+abs(gcd(w.x,w.y));
I=(A-E)/2+1;
printf("%d\n",I);
}
return 0;
}
POJ 2954 Triangle (pick 定理)的更多相关文章
- POJ 1265 Area POJ 2954 Triangle Pick定理
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5227 Accepted: 2342 Description ...
- poj 2954 Triangle 三角形内的整点数
poj 2954 Triangle 题意 给出一个三角形的三个点,问三角形内部有多少个整点. 解法 pick's law 一个多边形如果每个顶点都由整点构成,该多边形的面积为\(S\),该多边形边上的 ...
- poj 2954 Triangle(Pick定理)
链接:http://poj.org/problem?id=2954 Triangle Time Limit: 1000MS Memory Limit: 65536K Total Submissio ...
- poj 1265 Area (Pick定理+求面积)
链接:http://poj.org/problem?id=1265 Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: ...
- POJ 1265 Area (Pick定理 & 多边形面积)
题目链接:POJ 1265 Problem Description Being well known for its highly innovative products, Merck would d ...
- poj 1265 Area(pick定理)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4373 Accepted: 1983 Description Bein ...
- [poj 1265]Area[Pick定理][三角剖分]
题意: 给出机器人移动的向量, 计算包围区域的内部整点, 边上整点, 面积. 思路: 面积是用三角剖分, 边上整点与GCD有关, 内部整点套用Pick定理. S = I + E / 2 - 1 I 为 ...
- poj 1265 Area( pick 定理 )
题目:http://poj.org/problem?id=1265 题意:已知机器人行走步数及每一步的坐标 变化量 ,求机器人所走路径围成的多边形的面积.多边形边上和内部的点的数量. 思路:1.以 ...
- Area - POJ 1265(pick定理求格点数+求多边形面积)
题目大意:以原点为起点然后每次增加一个x,y的值,求出来最后在多边形边上的点有多少个,内部的点有多少个,多边形的面积是多少. 分析: 1.以格子点为顶点的线段,覆盖的点的个数为GCD(dx,dy),其 ...
随机推荐
- [转]毕设- 深入HBase架构解析(一)
深入HBase架构解析(一) 前记 公司内部使用的是MapR版本的Hadoop生态系统,因而从MapR的官网看到了这篇文文章:An In-Depth Look at the HBase Archi ...
- 优秀 H5 案例收集 vol.1(不定期更新)
一生要历经的三种战斗http://datang.wearewer.com/ 雍正去哪儿http://news.163.com/college/special/craftsman_h5/ 比Emoji更 ...
- ASP.NET MVC CheckBoxFor的int to bool
当我们使用CheckBoxFor类型需要使用bool ,可以将 int转换成bool <div class="form-group"> <label class= ...
- 安装pycurl
环境:ubuntu 1604 安装 pycurl 遇到一些问题 简单记录 1.安装 pippython2:apt install python-pippython3: apt install pyth ...
- springboot--配置文件加载顺序
-file:./config(内部配置) -file:./ (内部配置) -classpath:/config (外部配置) -classpath:/ (外部配置) 运维: spring -jar s ...
- 什么是webhook
什么是webhook 翻译,原文地址:https://sendgrid.com/blog/webhook-vs-api-whats-difference/ 一.概述 Webhook是一个API概念,并 ...
- yii2输出sql
yii2如何输出sql语句? 单表查询sql: 我的model是:coupon,那么sql输出为: $a = coupon::find()->createCommand()->getRaw ...
- oracle:查询数据表是否存在
oracle:查询数据表是否存在 select count(*) as NUM from all_tables where table_name = '{$table}' 或者: select cou ...
- java枚举和constant使用区别
本文结合<Effective Java>第六章前半部分关于枚举的介绍和自己的理解及实践,讲解了Java枚举的知识点.文章发布于专栏Effective Java,欢迎读者订阅. 前言 你代 ...
- js图片倒计时
var discountOnline = !{discountOnline} if (discountOnline) { _fresh() setInterval(_fresh, 1000); } v ...