题目描述:

vjudge

POJ

题解:

本以为是水题结果是神题

计算几何求多边形面积。

考虑到结果一定是整数或者整数/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的更多相关文章

  1. poj1654 -- Area (任意多边形面积)

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20444   Accepted: 5567 Description ...

  2. 【kuangbin专题】计算几何基础

    1.poj2318 TOYS 传送:http://poj.org/problem?id=2318 题意:有m个点落在n+1个区域内.问落在每个区域的个数. 分析:二分查找落在哪个区域内.叉积判断点与线 ...

  3. poj分类解题报告索引

    图论 图论解题报告索引 DFS poj1321 - 棋盘问题 poj1416 - Shredding Company poj2676 - Sudoku poj2488 - A Knight's Jou ...

  4. [转]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 ...

  5. ASP.NET MVC系列:Area

    1. Area简介 ASP.NET MVC Area机制构建项目,可以将相对独立的功能模块切割划分,降低项目的耦合度. 2. Area设置Routing 新建Admin Area后,自动创建Admin ...

  6. Web API项目中使用Area对业务进行分类管理

    在之前开发的很多Web API项目中,为了方便以及快速开发,往往把整个Web API的控制器放在基目录的Controllers目录中,但随着业务越来越复杂,这样Controllers目录中的文件就增加 ...

  7. MVC View中获取action、controller、area名称

    获取控制器名称: ViewContext.RouteData.Values["controller"].ToString(); 获取Action名称: ViewContext.Ro ...

  8. [LeetCode] Rectangle Area 矩形面积

    Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...

  9. 如何在Linux上使用文件作为内存交换区(Swap Area)

    交换区域(Swap Area)有什么作用? 交换分区是操作系统在内存不足(或内存较低)时的一种补充.通俗的说,如果说内存是汽油,内存条就相当于油箱,交换区域则相当于备用油箱. Ubuntu Linux ...

随机推荐

  1. GFS安装

    GlusterFS 搭建 1.环境要求 IP地址 主机名称 系统 172.16.2.201 test01 Centos 6.4 172.16.2.202 test02 Centos 6.4 172.1 ...

  2. ASPNET Core 2.x中的Kestrel服务器

    原文链接 Kestrel是一个基于libuv的跨平台ASP.NET Core web服务器,libuv是一个跨平台的异步I/O库.ASP.NET Core模板项目使用Kestrel作为默认的web服务 ...

  3. JS高级学习历程-12

    冒充继承 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/T ...

  4. Codeforces Round #566 (Div. 2) C. Beautiful Lyrics

    链接: https://codeforces.com/contest/1182/problem/C 题意: You are given n words, each of which consists ...

  5. [WPF自定义控件库]了解如何自定义ItemsControl

    1. 前言 对WPF来说ContentControl和ItemsControl是最重要的两个控件. 顾名思义,ItemsControl表示可用于呈现一组Item的控件.大部分时候我们并不需要自定义It ...

  6. c#基础值类和引用类型_字符串

    值类型和引用类型区别:1.值类型和引用类型在内存上存储的地方不一样.2.在传递值类型和传递引用类型的时候,传递的方式不一样.值类型我们称之为值传递,引用类型我们称之为引用传递.我们学的值类型和引用类型 ...

  7. 完整uploadify批量上传文件插件使用

    1.首先准备uploadify的js文件,网上一搜一大堆 2.上传页面UpFilePage.aspx 关键代码: <html xmlns="http://www.w3.org/1999 ...

  8. ThreadLocal源码解析,内存泄露以及传递性

    我想ThreadLocal这东西,大家或多或少都了解过一点,我在接触ThreadLocal的时候,觉得这东西很神奇,在网上看了很多博客,也看了一些书,总觉得有一个坎跨不过去,所以对ThreadLoca ...

  9. Spring注入属性、对象

    对Category和Product注入属性,并且对Product对象,注入一个Category对象 一.新建项目 二.导包 三.新建Category类 package com.yyt.pojo; pu ...

  10. 关于使用mybatis的分页插件问题

    首先我需要导入架包 1.pagehelper 如果你是在mybatis中配置分页‘ 如下代码 <plugins> <plugin interceptor="com.gith ...