有一种定理,叫毕克定理。。。。

                            Area
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 4352   Accepted: 1977

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 system of surveillance robots patrolling the area. These robots move along the walls of the facility and report suspicious observations to the central security office. The only flaw in the system a competitor抯 agent could find is the fact that the robots radio their movements unencrypted. Not being able to find out more, the agent wants to use that information to calculate the exact size of the area occupied by the new facility. It is public knowledge that all the corners of the building are situated on a rectangular grid and that only straight walls are used. Figure 1 shows the course of a robot around an example area.

 
Figure 1: Example area. 
You are hired to write a program that calculates the area occupied by the new facility from the movements of a robot along its walls. You can assume that this area is a polygon with corners on a rectangular grid. However, your boss insists that you use a formula he is so proud to have found somewhere. The formula relates the number I of grid points inside the polygon, the number E of grid points on the edges, and the total area A of the polygon. Unfortunately, you have lost the sheet on which he had written down that simple formula for you, so your first task is to find the formula yourself. 

Input

The first line contains the number of scenarios. 
For each scenario, you are given the number m, 3 <= m < 100, of movements of the robot in the first line. The following m lines contain pairs 揹x dy�of integers, separated by a single blank, satisfying .-100 <= dx, dy <= 100 and (dx, dy) != (0, 0). Such a pair means that the robot moves on to a grid point dx units to the right and dy units upwards on the grid (with respect to the current position). You can assume that the curve along which the robot moves is closed and that it does not intersect or even touch itself except for the start and end points. The robot moves anti-clockwise around the building, so the area to be calculated lies to the left of the curve. It is known in advance that the whole polygon would fit into a square on the grid with a side length of 100 units. 

Output

The output for every scenario begins with a line containing 揝cenario #i:� where i is the number of the scenario starting at 1. Then print a single line containing I, E, and A, the area A rounded to one digit after the decimal point. Separate the three numbers by two single blanks. Terminate the output for the scenario with a blank line.

Sample Input

2
4
1 0
0 1
-1 0
0 -1
7
5 0
1 3
-2 2
-1 0
0 -3
-3 1
0 -3

Sample Output

Scenario #1:
0 4 1.0

Scenario #2:
12 16 19.0

Source

 
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const int maxn=; int gcd(int a,int b)
{
return b==?a:gcd(b,a%b);
} struct point
{
double x,y;
point() {}
point(double a,double b):x(a),y(b){}
}; double det(point a,point b)
{
return a.x*b.y-a.y*b.x;
} struct polyon
{
int n;
point a[maxn];
polyon() {}
double GetArea()
{
double sum=;
a[n]=a[];
for(int i=;i<n;i++)
{
sum+=det(a[i+],a[i]);
}
return fabs(sum/.);
} int Border_Int_Point_Num()
{
int num=;
a[n]=a[];
for(int i=;i<n;i++)
{
num+=gcd(abs(int(a[i+].x-a[i].x)),abs(int(a[i+].y-a[i].y)));
}
return num;
} int Inside_Int_Point_Num(int x,double area)
{
return int(area)+-x/;
}
}PY; int main()
{
int t,cas=;
scanf("%d",&t);
while(t--)
{
scanf("%d",&PY.n);
int X=,Y=;
for(int i=;i<PY.n;i++)
{
int a,b;
scanf("%d%d",&a,&b);
X+=a; Y+=b;
PY.a[i].x=X; PY.a[i].y=Y;
}
double area=PY.GetArea();
int On=PY.Border_Int_Point_Num();
int In=PY.Inside_Int_Point_Num(On,area);
printf("Scenario #%d:\n",cas++);
printf("%d %d %.1lf\n\n",In,On,area);
}
return ;
}

POJ 1265 Area的更多相关文章

  1. poj 1265 Area 面积+多边形内点数

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5861   Accepted: 2612 Description ...

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

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

  3. POJ 1265 Area (Pick定理 & 多边形面积)

    题目链接:POJ 1265 Problem Description Being well known for its highly innovative products, Merck would d ...

  4. poj 1265 Area( pick 定理 )

    题目:http://poj.org/problem?id=1265 题意:已知机器人行走步数及每一步的坐标   变化量 ,求机器人所走路径围成的多边形的面积.多边形边上和内部的点的数量. 思路:1.以 ...

  5. poj 1265 Area【计算几何:叉积计算多边形面积+pick定理计算多边形内点数+计算多边形边上点数】

    题目:http://poj.org/problem?id=1265 Sample Input 2 4 1 0 0 1 -1 0 0 -1 7 5 0 1 3 -2 2 -1 0 0 -3 -3 1 0 ...

  6. POJ 1265 Area POJ 2954 Triangle Pick定理

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5227   Accepted: 2342 Description ...

  7. poj 1265 Area(Pick定理)

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5666   Accepted: 2533 Description ...

  8. poj 1265 Area(pick定理)

    Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4373 Accepted: 1983 Description Bein ...

  9. 2018.07.04 POJ 1265 Area(计算几何)

    Area Time Limit: 1000MS Memory Limit: 10000K Description Being well known for its highly innovative ...

随机推荐

  1. 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 2 Random sampling with and without replacement

    Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  2. UVa 1025 A Spy in the Metro(动态规划)

    传送门 Description Secret agent Maria was sent to Algorithms City to carry out an especially dangerous ...

  3. css006 文本格式化

    css006 文本格式化 文本格式化:字体(font-family).颜色(color).字号(font-size). 行距(line-height).粗体(font-weight).斜体(font- ...

  4. c#正则表达式2

    System.Text.RegularExpressions.Regex ___rx = new System.Text.RegularExpressions.Regex(@""& ...

  5. docker mysql

    创建mysql docker容器 github上有一个专门的docker-libary项目,里面有各种各样常用的docker镜像,可以做为学习的示例,今天研究下其中mysql镜像的用法,国内镜像dao ...

  6. Java国际化程序

    根据不同的国家配置不同的资源文件(资源文件有时也称为属性文件,后缀为.properties),所有的资源文件以键值对的形式出现. Locale类 ResourceBundle类 //========= ...

  7. JavaScript学习笔记——函数

    javascript函数的声明和调用 将完成某一特定功能的代码集合起来,可以重复使用的代码块. 一.函数的声明方式(创建) A.基本语法 function 关键字 function 函数名([参数1] ...

  8. Centos6.5安装和使用docker

    rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum install docke ...

  9. fixed的left:50%,漂浮

    .floor-box{width: 44px; border: 1px solid #ccc; position: %; z-index: } 漂浮距离,距中间50% .floor-box{width ...

  10. Linux负载均衡软件LVS简介

    Linux负载均衡软件LVS LVS集群的体系结构以及特点 1. LVS简介        LVS是Linux Virtual Server的简称,也就是Linux虚拟服务器, 是一个由章文嵩博士发起 ...