POJ 1654 Area 计算几何
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
int dx[]={,,,,,,,-,-,-};
int dy[]={,-,,,-,,,-,,};
char s[];
__int64 area,x,y,px,py;
int main()
{
int sum,t,tmp,i;
cin>>tmp;
while(tmp--)
{
scanf("%s",s);
t=strlen(s);
if(t<)
{
printf("0\n");
}
else
{
area=;
x=y=;
for(i=;i<t-;i++)
{
px=x+dx[s[i]-''];
py=y+dy[s[i]-''];
area+=(px*y-x*py);
x=px;
y=py;
}
area=fabs(area);
if(area%==)
cout<<area/<<endl;
else
cout<<area/<<".5"<<endl;
}
}
return ;
}
计算几何,让原点和相邻的两个点的坐标进行叉乘,然后累加起来/2就是面积
由于数据的特殊性质,所有最后%2来判断是否有小数点
POJ 1654 Area 计算几何的更多相关文章
- poj 1654 Area 多边形面积
/* poj 1654 Area 多边形面积 题目意思很简单,但是1000000的point开不了 */ #include<stdio.h> #include<math.h> ...
- 2018.07.04 POJ 1654 Area(简单计算几何)
Area Time Limit: 1000MS Memory Limit: 10000K Description You are going to compute the area of a spec ...
- poj 1654 Area (多边形求面积)
链接:http://poj.org/problem?id=1654 Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: ...
- poj 1654 Area(计算几何--叉积求多边形面积)
一个简单的用叉积求任意多边形面积的题,并不难,但我却错了很多次,double的数据应该是要转化为long long,我转成了int...这里为了节省内存尽量不开数组,直接计算,我MLE了一发...,最 ...
- poj 1654 Area(多边形面积)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17456 Accepted: 4847 Description ...
- poj 1654 Area(求多边形面积 && 处理误差)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 16894 Accepted: 4698 Description ...
- POJ 1654 area 解题
Description You are going to compute the area of a special kind of polygon. One vertex of the polygo ...
- POJ 1654 Area(水题)
题目链接 卡了一下精度和内存. #include <cstdio> #include <cstring> #include <string> #include &l ...
- POJ 1654 Area
题意:从原点出发,沿着8个方向走,每次走1个点格或者根号2个点格的距离,最终回到原点,求围住的多边形面积. 分析:直接记录所经过的点,然后计算多边形面积.注意,不用先保存所有的点,然后计算面积,边走变 ...
随机推荐
- nginx自定义500,502,504错误页面无法跳转【转】
1.自定一个页面,这个页面是一个链接地址可以直接访问的. 以下是nginx的配置: location / { proxy_pass http://tomcat_app108; ...
- inspect的使用
# -*- coding: utf-8 -*- # @Time : 2018/9/11 10:29 # @Author : cxa # @File : inspecttest.py # @Softwa ...
- jquery记忆笔记
1.javascript需要注意的一些问题: ①不要使用==比较,始终坚持使用===比较. false == 0; // true false === 0; // false ②NaN这个特殊的Num ...
- 读书笔记 effective c++ Item 48 了解模板元编程
1. TMP是什么? 模板元编程(template metaprogramming TMP)是实现基于模板的C++程序的过程,它能够在编译期执行.你可以想一想:一个模板元程序是用C++实现的并且可以在 ...
- js 去除字符串所有空格
function trim(str){ return str.replace(/\s|\xA0/g,""); }
- iframe框架加载完成后执行函数
var iframe = document.createElement("iframe"); iframe.src = "http://www.baidu.com/&qu ...
- AdvStringGrid 标题头
标题头内容: 字体: 标题头高度: 头的对齐方式:
- ZooKeeper的典型应用场景
<从Paxos到Zookeeper 分布式一致性原理与实践>读书笔记 本文:总结脑图地址:脑图 前言 所有的典型应用场景,都是利用了ZK的如下特性: 强一致性:在高并发情况下,能够保证节点 ...
- ubuntu和windows双系统启动顺序的修改
ubuntu和windows双系统启动顺序的修改 说到启动就不得不说GRUB,Linux下大名鼎鼎的启动管理工具(曾经的LILO已经风光不再),当然现在已经是GRUB2了,GRUB2和GRUB最重要的 ...
- Python学习笔记:bisect模块实现二分搜索
在Python中可以利用bisect模块来实现二分搜索,该模块包含函数只有几个: import bisect L = [1,3,4,5,5,5,8,10] x = 5 bisect.bisect_le ...