链接

 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. python day5--正则表达式

    #----正则表达式 import re elink = '<a href="(.*)">(.*)</a>' info = '<a href=&quo ...

  2. K - Work 分类: 比赛 2015-07-29 19:13 3人阅读 评论(0) 收藏

    K - Work Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  3. 从hadoop框架与MapReduce模式中谈海量数据处理

    http://blog.csdn.net/wind19/article/details/7716326 前言 几周前,当我最初听到,以致后来初次接触Hadoop与MapReduce这两个东西,我便稍显 ...

  4. TCP数据流稳定性--TCP分片,重组及乱序

    http://www.cnblogs.com/derekchen/archive/2009/07/15/1524415.html 1.IP分片的情况.IP软件包有一个[分片]和[重组]模块,一个IP数 ...

  5. UVa 10054,欧拉回路

    题目链接:https://uva.onlinejudge.org/external/100/10054.pdf 题目链接:http://vjudge.net/contest/132239#proble ...

  6. shell基础知识

    Shell 学习基础 1.组合命令的符号 管道,将前面一个命令的结果作为后面一个命令的输入 分号,顺序执行用分号分割的命令 重定向,重定向包括三种:输入重定向.输出重定向.错误重定向,以7个不同的符号 ...

  7. Mysql-学习笔记(==》权限管理 十 三)

    -- 用户与权限管理-- 查看当前服务器上的所有账号密码主机SELECT USER,PASSWORD,HOST FROM mysql.user; -- 设置账号密码SET PASSWORD=PASSW ...

  8. Mysql-学习笔记(==》增删主键建立索引 七)

    SHOW FULL COLUMNS FROM teacher; -- 增加删除主键 alterCREATE TABLE tt(t INT);ALTER TABLE tt ADD CONSTRAINT ...

  9. Web文件的ContentType类型收集

    ".*"="application/octet-stream"".001"="application/x-001"&qu ...

  10. 去处HTML标签

    JavaScript去处HTML标签 function removeHTMLTag(str) { str = str.replace(/<\/?[^>]*>/g, ''); //去除 ...