POJ 1654 Area
// Time 94ms; Memory 1036K
#include<iostream>
#include<cstring>
#define maxn 1000010 using namespace std; char s[maxn];
long long dx[]={-1,0,1,-1,0,1,-1,0,1},dy[]={-1,-1,-1,0,0,0,1,1,1}; struct point
{
long long x,y;
point(long long xx=0,long long yy=0):x(xx),y(yy){}
}a,b; long long cross()
{
return a.x*b.y-a.y*b.x;
}
int main()
{
int i,t,l;
long long are;
cin>>t;
while(t--)
{
cin>>s;
l=strlen(s);
if(l<2)
{
cout<<"0"<<endl;continue;
}
a=point(dx[s[0]-49],dy[s[0]-49]);
b=point(a.x+dx[s[1]-49],a.y+dy[s[1]-49]);
are=cross();
for(i=2;s[i];i++)
{
a=b;
b=point(a.x+dx[s[i]-49],a.y+dy[s[i]-49]);
are+=cross();
}
if(are<0) are=-are;
cout<<are/2;
if(are%2) cout<<".5";
cout<<endl;
}
return 0;
}
POJ 1654 Area的更多相关文章
- poj 1654 Area 多边形面积
/* poj 1654 Area 多边形面积 题目意思很简单,但是1000000的point开不了 */ #include<stdio.h> #include<math.h> ...
- poj 1654 Area (多边形求面积)
链接:http://poj.org/problem?id=1654 Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: ...
- poj 1654 Area(多边形面积)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17456 Accepted: 4847 Description ...
- 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(求多边形面积 && 处理误差)
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 16894 Accepted: 4698 Description ...
- poj 1654 Area(计算几何--叉积求多边形面积)
一个简单的用叉积求任意多边形面积的题,并不难,但我却错了很多次,double的数据应该是要转化为long long,我转成了int...这里为了节省内存尽量不开数组,直接计算,我MLE了一发...,最 ...
- POJ 1654 Area 计算几何
#include<stdio.h> #include<string.h> #include<iostream> #include<math.h> usi ...
- 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 ...
随机推荐
- 8.无法訪问developer.android.com的解决方式。
问题:无法訪问developer.android.com,就无法知道Android的最新信息. 解决的方法:寻找国外的代理ip,比方http://www.xici.net.co/上面的国外代理ip. ...
- Struts2_2_第一Struts2应用
web.xml文件的配置与1同样. 1)HelloWorld类的代码: public class HelloWorldAction { private String message; public S ...
- Windows系统服务的编写。
实验资源下载地址:点击打开链接 只是不知道能不能从服务向桌面进程传递消息,,就像两个桌面进程之间用Sendmessage似的..希望有知道的大神可以指点一下..不胜感激.. 因为微软在Vista之后, ...
- 微软不也是从Altair Basic这丑小鸭长成白天鹅吗?
微软不也是从Altair Basic这丑小鸭长成白天鹅吗? February 2015 如果你想要弄清楚初创企业是怎么一回事的话,其中一个非常有价值的尝试是去研究下那些获得巨大成功的公司,去分析下为什 ...
- JS子元素oumouseover触发父元素onmouseout
原文:JS子元素oumouseover触发父元素onmouseout JavaScript中,父元素包含子元素: 当父级设置onmouseover及onmouseout时,鼠标从父级移入子级,则触发父 ...
- IISExpress配置文件
ASP.NET MVC IISExpress配置文件的一个坑 现象: 昨天在处理PBS系统问题的时候意外发现两个js错误(而同样的代码在同事机器上都没有问题),如下图. 图1 图2 图3 原因分析: ...
- selenium2入门 定位 窗体切换等等 (二)
定位用的html素材有两个 demo.html <html> <head> <title>UI Automation Testing</title> & ...
- Visual Studio 2010 单元测试--运行测试并查看代码覆盖率
原文:Visual Studio 2010 单元测试--运行测试并查看代码覆盖率 运行测试并查看代码覆盖率对程序集中的代码运行测试时,可以通过收集代码覆盖率数据来查看正在测试的项目代码部分. 运行测试 ...
- [代码收藏]设为首页和加入收藏的JavaScript代码(兼容多浏览器)
其实不少非IE内核浏览器都仍不支持通过代码将网页设为主页和加入收藏的功能,因此说是兼容,其实只是一个try,catch后的提醒而已. 加入收藏: /* * author : 2010-12-27 11 ...
- Spring.Net+Nhibernate+Asp.Net Mvc 框架
搭建你的Spring.Net+Nhibernate+Asp.Net Mvc 框架 (一)搭建你的环境 使用这套框架不是很长时间.但也基本应用了几个项目中了.在此和大家分享一下我是怎样一步一步搭建此框架 ...