链接

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

pick定理的一些应用

题意不好懂,给出的x,y并不是坐标而是向x轴方向y轴方向移动的距离。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 110
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y) {}
}p[N];
typedef Point pointt;
pointt operator + (Point a,Point b)
{
return Point(a.x+b.x,a.y+b.y);
}
pointt operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
}
double cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
double Polyarea(int n)
{
double area = ;
for(int i = ; i < n- ; i++)
area+=cross(p[i]-p[],p[i+]-p[]);
return area/;
}
int main()
{
int t,i,n,kk=;
cin>>t;
while(t--)
{
scanf("%d",&n);
int num = ;
p[].x = ,p[].y = ;
for(i = ; i <= n ;i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y);
p[i].x+=p[i-].x;
p[i].y+=p[i-].y;
}
p[n+] = ;
for(i = ; i <= n ;i++)
{
Point pp = p[i]-p[i+];
pp.x = fabs(pp.x),pp.y = fabs(pp.y);
if(dcmp(pp.x)==||dcmp(pp.y)==)
num+=pp.x+pp.y;
else
num+=__gcd((int)pp.x,(int)pp.y);
}
double s = Polyarea(n);
printf("Scenario #%d:\n",++kk);
printf("%d %d %.1f\n",(int)s+-num/,num,s);
puts("");
}
return ;
}

poj1265Area(pick定理)的更多相关文章

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

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

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

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

  3. 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 ...

  4. Area(Pick定理POJ1256)

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

  5. poj 2954 Triangle(Pick定理)

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

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

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

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

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

  8. UVa 10088 (Pick定理) Trees on My Island

    这种1A的感觉真好 #include <cstdio> #include <vector> #include <cmath> using namespace std ...

  9. POJ1265——Area(Pick定理+多边形面积)

    Area DescriptionBeing well known for its highly innovative products, Merck would definitely be a goo ...

随机推荐

  1. C#小知识点

    1.显示|隐示转换: public static explicit operator ImplicitClass(ExplicitClass explicitClass) //implicit { I ...

  2. linux下访问中文目录文件

    文件路径包含中文时,可输入部分文件名,然后按Tab键. 当路径包含中文括号时,用斜杠,如: \(….\) . 也可用 ls -li ,先查看inum(inode编号),然后再根据编号进行访问,用查找命 ...

  3. ACM题目————Subsequence

    Description A sequence of N positive integers (10 < N < 100 000), each of them less than or eq ...

  4. C类地址

    C类地址第1字节.第2字节和第3个字节为网络地址,第4个字节为主机地址.另外第1个字节的前三位固定为110. C类地址范围:192.0.0.1到223.255.255.255.(第1个字节的二进制值前 ...

  5. preparedStatement和Statement 有什么不一样

    1. PreparedStatement接口继承Statement, PreparedStatement 实例包含已编译的 SQL 语句,所以其执行速度要快于 Statement 对象.    2.作 ...

  6. 安装opencv以及遇到的坑

    参考这篇文章: http://www.tuicool.com/articles/36fMnem 还是国外的文章靠谱: http://docs.opencv.org/master/dd/dd5/tuto ...

  7. 公共控件Listview

    ListView属性中,Items是行的总集合,Items集合中的每一个是一行,Items集合里面有ListViewItem集合,这个集合实例化:ListViewItem li=new ListVie ...

  8. 编译android源码官方教程(5)编译完之后刷机、编译fastboot

    Running Builds IN THIS DOCUMENT Building fastboot and adb Booting into fastboot mode Unlocking the b ...

  9. java获取指定时间的年月日

    作者:Night Silent链接:http://www.zhihu.com/question/35650798/answer/63983440来源:知乎著作权归作者所有,转载请联系作者获得授权.1. ...

  10. loadrunner安装汉化破解

    1.解压loadrunner11,点击setup.exe安装loadrunner11. 遇到问题,"...输入命令\来解决". 解决办法:运行解压包的loadrunner-11安装 ...