题目大意:已知机器人行走步数及每一步的坐标变化量,求机器人所走路径围成的多边形的面积、多边形边上和内部的点的数量。

思路:叉积求面积,pick定理求点。

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

// Time 0ms; Memory 236K
#include<iostream>
#include<cstdio>
#include<cmath> using namespace std; struct point
{
int x,y;
point(int xx=0,int yy=0):x(xx),y(yy){}
}a,b;
int gcd(int x,int y)
{
static int t;
for(;t=y;y=x%y,x=t);
return x;
}
int main()
{
int i,j,t,m,p,q,A,I,E;
cin>>t;
for(i=0;i<t;i++)
{
A=E=0;
cin>>m;
for(j=0;j<m;j++)
{
cin>>p>>q;
a=b;
b=point(a.x+p,a.y+q);
A+=a.x*b.y-a.y*b.x;
E+=abs(gcd(a.x-b.x,a.y-b.y));
}
A=abs(A);
I=(A-E)/2+1; //pick定理
printf("Scenario #%d:\n",i+1);
printf("%d %d %.1lf\n\n",I,E,A*0.5);
}
return 0;
}

POJ 1265 Area (pick定理)的更多相关文章

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

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

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

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

  3. poj 1265 Area(pick定理)

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

  4. [poj 1265]Area[Pick定理][三角剖分]

    题意: 给出机器人移动的向量, 计算包围区域的内部整点, 边上整点, 面积. 思路: 面积是用三角剖分, 边上整点与GCD有关, 内部整点套用Pick定理. S = I + E / 2 - 1 I 为 ...

  5. poj 1265 Area( pick 定理 )

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

  6. Area - POJ 1265(pick定理求格点数+求多边形面积)

    题目大意:以原点为起点然后每次增加一个x,y的值,求出来最后在多边形边上的点有多少个,内部的点有多少个,多边形的面积是多少. 分析: 1.以格子点为顶点的线段,覆盖的点的个数为GCD(dx,dy),其 ...

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

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

  8. POJ 1265 Area POJ 2954 Triangle Pick定理

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

  9. poj 1265 Area(Pick定理)

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

随机推荐

  1. Ubuntu16.04安装Appium

    准备工作 1.安装Node 下载地址:https://nodejs.org/en/download/ 下载完后解压,设置环境变量 配置Node环境变量$sudo vim /etc/profile 在文 ...

  2. CSS 边距和填充

    margin and padding are the two most commonly used properties for spacing-out elements. A margin is t ...

  3. MySQL Binlog解析(2)

    一.TABLE_MAP_EVENT Used for row-based binary logging beginning with MySQL 5.1.5.The TABLE_MAP_EVENT d ...

  4. Java设计模式学习之工厂模式

    在Java(或者叫做面向对象语言)的世界中,工厂模式被广泛应用于项目中,也许你并没有听说过,不过也许你已经在使用了.Java 设计模式之工厂模式 简单来说,工厂模式的出现源于增加程序序的可扩展性,降低 ...

  5. Autofac register and resolve

    Passing Parameters to Register When you register components you have the ability to provide a set of ...

  6. Android -- ContentProvider 内容提供者,创建和调用

    1. 概述 ContentProvider 在android中的作用是对外共享数据,也就是说你可以通过ContentProvider把应用中的数据共享给其他应用访问,其他应用可以通过ContentPr ...

  7. SSH2 增删查改实例

    (一)引入包 (共73个,不一定都需要,但是我的项目是这么多,经过调试,没有包冲突) (二)创建数据库表 建立数据库octtest,并创建user表,表里面一共4个字段:id,姓,名,年龄. 语句如下 ...

  8. TypeScript 教程&手册

    参考:https://www.w3cschool.cn/typescript/ https://www.gitbook.com/book/zhongsp/typescript-handbook/det ...

  9. spirng: srping mvc配置(访问路径配置)搭建SpringMVC——最小化配置

    搭建SpringMVC——最小化配置 最开始接触网页的时候,是纯的html/css页面,那个时候还是用Dreamweaver来绘制页面. 随着网站开发的深入,开始学习servlet开发,记得最痛苦的就 ...

  10. 为啥YII2 会出现 mcrypt_generic_init(): Key size is 0

    解决方案如下: (关键) 示例代码中,加密解密类的实例创见通过 Class 同名方法 的方式创建. public function WXBizMsgCrypt($token, $encodingAes ...