poj1654 Area
题目描述:
题解:
本以为是水题结果是神题
计算几何求多边形面积。
考虑到结果一定是整数或者整数/2,我们应该用long long 来存……
用double会死……
还有日常只能用c++编译器,不能用g++。
还有用abs会莫名ce,要手写。
代码:
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
struct Point
{
ll x,y;
Point(){}
Point(ll x,ll y):x(x),y(y){}
Point operator + (const Point&a)const{return Point(x+a.x,y+a.y);}
Point operator - (const Point&a)const{return Point(x-a.x,y-a.y);}
ll operator ^ (const Point&a)const{return x*a.y-y*a.x;}
}p[];
typedef Point Vector;
int T;
char ch[];
void init()
{
p[] = Point(-,-),p[] = Point(,-),p[] = Point(,-),p[] = Point(-,);
p[] = Point(,),p[] = Point(-,),p[] = Point(,),p[] = Point(,);
}
void work()
{
scanf("%s",ch+);
Point s0(,),s1(,),s2(,);
int len = strlen(ch+);
long long ans = ;
for(int i=;i<len;i++)
{
s1 = s2,s2 = s2+p[ch[i]-''];
ans+=((s1-s0)^(s2-s0));
}
if(ans<)ans=-ans;
if(ans&)
{
printf("%lld.5\n",ans/);
}else
{
printf("%lld\n",ans/);
}
}
int main()
{
scanf("%d",&T);init();
while(T--)work();
return ;
}
poj1654 Area的更多相关文章
- poj1654 -- Area (任意多边形面积)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 20444 Accepted: 5567 Description ...
- 【kuangbin专题】计算几何基础
1.poj2318 TOYS 传送:http://poj.org/problem?id=2318 题意:有m个点落在n+1个区域内.问落在每个区域的个数. 分析:二分查找落在哪个区域内.叉积判断点与线 ...
- poj分类解题报告索引
图论 图论解题报告索引 DFS poj1321 - 棋盘问题 poj1416 - Shredding Company poj2676 - Sudoku poj2488 - A Knight's Jou ...
- [转]NopCommerce How to add a menu item into the administration area from a plugin
本文转自:http://docs.nopcommerce.com/display/nc/How+to+code+my+own+shipping+rate+computation+method Go t ...
- ASP.NET MVC系列:Area
1. Area简介 ASP.NET MVC Area机制构建项目,可以将相对独立的功能模块切割划分,降低项目的耦合度. 2. Area设置Routing 新建Admin Area后,自动创建Admin ...
- Web API项目中使用Area对业务进行分类管理
在之前开发的很多Web API项目中,为了方便以及快速开发,往往把整个Web API的控制器放在基目录的Controllers目录中,但随着业务越来越复杂,这样Controllers目录中的文件就增加 ...
- MVC View中获取action、controller、area名称
获取控制器名称: ViewContext.RouteData.Values["controller"].ToString(); 获取Action名称: ViewContext.Ro ...
- [LeetCode] Rectangle Area 矩形面积
Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...
- 如何在Linux上使用文件作为内存交换区(Swap Area)
交换区域(Swap Area)有什么作用? 交换分区是操作系统在内存不足(或内存较低)时的一种补充.通俗的说,如果说内存是汽油,内存条就相当于油箱,交换区域则相当于备用油箱. Ubuntu Linux ...
随机推荐
- 关于HTML5画布canvas的功能
一.画布的使用 1.首先创建一个画布(canvas) <canvas id=”myCanvas” width=”200” height=”100” style=”border:1px solid ...
- 对于BeanUtils类的方法populate的一些个人拙见
今天在做一个登录案列,期间涉及到了BeanUtils类,这个类也是第一次涉及到,视频没有细讲.只能自己摸着石头过河.慢慢思考.下面来说一下自己个人对这个类的方法populate的理解 这个类应该不是单 ...
- java.exe is valid, but is for a machine type other than the current machine
java.exe is valid, but is for a machine type other than the current machine jdk版本不一致问题,在32位机器上使用64位的 ...
- 服务器安装docker后免除sudo命令
1. 先建立一个docker组:sudo groupadd docker 2. 将用户加入docker组:sudo usermod -aG docker (用户名) 3. 先退出登录:exit 4. ...
- 3.过滤数据 ---SQL
一.使用WHERE子句 SELECT prod_name, prod_price FROM Products WHERE prod_price = 3.49; 输出▼ prod_name prod_p ...
- jQuery基础(1)
一.jQuery的介绍 1.为什么要使用jQuery? 在用js写代码时,会遇到一些问题,如下: 1)window.onload 事件有事件覆盖的问题,因此只能写一个事件: 2)代码容错性差: 3)浏 ...
- Http请求数据解释
请求的数据里面包含三个部分内容 : 请求行 . 请求头 .请求体 请求行 POST /examples/servlets/servlet/RequestParamExample HTTP/1.1 PO ...
- NET Core & Entity Framework Core
ABP 教程文档 1-1 手把手引进门之 ASP.NET Core & Entity Framework Core(官方教程翻译版 版本3.2.5) 本文是ABP官方文档翻译版,翻译基于 ...
- 转Keil 中使用 STM32F4xx 硬件浮点单元
Keil 中使用 STM32F4xx 硬件浮点单元一.前言有工程师反应说 Keil 下无法使用 STM32F4xx 硬件浮点单元, 导致当运算浮点时运算时间过长,还有 一些人反应不知如何使用芯片芯片内 ...
- Jexus~docker与它产生了暖味
前段时间写了很多docker for .net core的文章,用来快速部署微服务相当给力,而尝到了香头的我们希望把.net frameworks的程序也使用docker来部署一下,那么接下来我就结果 ...