链接

 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. android5.x以上 状态栏透明的问题

    1.先在style中把 statusBarColor 设置为透明  如下 <item name="android:statusBarColor">@android:co ...

  2. [BIM]BIM中IFC介绍

    ifc是干什么的,看下图 ifc架构图 下文转自:http://www.bimcn.org/cjwt/201506053789.html IFC目前是国际通用的BIM标准,现在很多BIM软件都采用其作 ...

  3. C#string常用函数总结

    补充:             1:在C语言里 char占1个字节 而在C#,Java里char占两个字节 数据库里char 中汉占两个字节 字母数字占一个字             2:string ...

  4. 新注册域名greenopen.site,向专业道路进军

    新注册域名greenopen.site,向专业道路进军,欢迎访问!届时可以通过 greenopen.site jsxyhelu.github.io 或者jsxyhelu.cnblogs.com 访问本 ...

  5. 对于数据包的截取,使用linux中的netfilter钩子函数

    http://blog.csdn.net/wswifth/article/details/5115358 在师哥的代码(packet.c)中使用的是Linux2.4内核中的一个子系统:netfilte ...

  6. Unix下五种IO模型

    http://blog.chinaunix.net/uid-25324849-id-247813.html 1. I/O模型 Unix下共有五种I/O模型 a. 阻塞I/O b. 非阻塞I/O c. ...

  7. Python学习笔记-Day2-Python基础之列表操作

    列表的常用操作包括但不限于以下操作: 列表的索引,切片,追加,删除,切片等 这里将对列表的内置操作方法进行总结归纳,重点是以示例的方式进行展示. 使用type获取创建对象的类 type(list) 使 ...

  8. linux设备驱动编写_tasklet机制

    在编写设备驱动时, tasklet 机制是一种比较常见的机制,通常用于减少中断处理的时间,将本应该是在中断服务程序中完成的任务转化成软中断完成. 为了最大程度的避免中断处理时间过长而导致中断丢失,有时 ...

  9. linux下查看电脑配置

    1. 查看cpu ~$ cat /proc/cpuinfo 2. 查看内存占用 ~$ cat /proc/meminfo 3. 硬盘分区 $ cat /proc/partitions 4. ubunt ...

  10. 在vs中怎样一次性的添加一个文件夹到解决方案里

    这个方法通常用到编译源码库方面,在这里我以编译静态库为例: 1.首先建立自己的工程Mytest 第二步 选择静态库 点击finish 完成工程的建立 第三步 点击PROJECT菜单项 选中Show A ...