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 ...
随机推荐
- SpringBoot2.0 基础案例(07):集成Druid连接池,配置监控界面
一.Druid连接池 1.druid简介 Druid连接池是阿里巴巴开源的数据库连接池项目.Druid连接池为监控而生,内置强大的监控功能,监控特性不影响性能.功能强大,能防SQL注入,内置Login ...
- java基础第十二篇之集合、增强for循环、迭代器和泛型
Collection接口中的常用方法: * 所有的子类子接口都是具有的 * 集合的方法:增删改查 * * public boolean add(E e);//添加元素 返回值表示是否添加成功 * pu ...
- ldap 报错整理
1.httpd 无法启动 先用systemctl status httpd 查看一下日志 1.提示端口号是否冲突,修改httpd.conf端口号 2.提示没有权限:检查selinux,防火墙是否关闭或 ...
- Linux上部署黑马旅游网Bug集锦
- WEB安全字体(Web Safe Fonts)-网页设计用什么字体兼容性好?
效果:http://sandbox.runjs.cn/show/qgdljvh4 1 Arial微软公司的网页核心字体之一,最常用的sans serif字体,当字号很小时不容易阅读.但是,大写的“I” ...
- HDU-1179-Ollivanders(二分图最大匹配)
链接:https://vjudge.net/problem/HDU-1179 题意: 有n个法师和m个魔棒,每个法师喜欢多种魔棒,但每个法师只能在喜欢的魔棒中选一个. 求最多有几个法师能选到魔棒. 思 ...
- Netty(2)Echo
上节介绍的是discard协议,即不给客户端返回消息.本节主要说下,echo协议,即服务端收到消息后原样返回给客户端. 为了实现此需求,只需要在DiscardServerHandler中重写chann ...
- js和jq中常见的各种位置距离之offset()和position()的区别(二)
offset()返回的是相对于当前文档的坐标,position()返回的是相对于其定位的祖辈元素的坐标. 使用position()方法时事实上是把该元素当绝对定位来处理,获取的是该元素相当于最近的一个 ...
- Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/common/base/Function : Unsupported major.minor version 52.0的解决办法(图文详解)
不多说,直接上干货! 问题详情 Exception in thread "main" java.lang.UnsupportedClassVersionError: com/goo ...
- nginx的基本操作
启动 nginx -c /etc/nginx/nginx.conf停止nginx -s stop nginx -s quit pkill -9 nginx重载nginx -s reload文件检测ng ...