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 ...
随机推荐
- javascript5
调用对象call object: 声明上下文对象declarative environment record; 作用域链scopechain: 变量解析:variable resolution: 引用 ...
- Oracle 11g for Windows 简体中文版的安装过程
原文:Oracle 11g for Windows 简体中文版的安装过程 我的配置 操作系统:Windows Server 2003 sp2 内存:1024M以上 1.下载Oracle 11g 地址 ...
- 快速构建Windows 8风格应用30-应用生命周期管理
原文:快速构建Windows 8风格应用30-应用生命周期管理 引言 Windows 8 中可以启动多个应用并在其中切换,我们没有必要担心降低系统速度或消耗电池电量. 因为系统会自动挂起(有时会终止) ...
- UpdateModel方法
WebForm 对 MVC 说:能否借你的UpdateModel方法来用用? 背景 ASP.NET MVC的Controller有个很不错的方法:UpdataModel (相对应的还有TryUpdat ...
- OWIN产生的背景以及简单介绍
OWIN产生的背景以及简单介绍 随着VS2013的发布,微软在Asp.Net中引入了很多新的特性,比如使用新的权限验证模块Identity, 使用Async来提高Web服务器的吞吐量和效率等.其中一个 ...
- Winform无边框窗体(FormBorderStyle属性设为None)自定义移动
为了界面的好看,有时候需要将窗体FormBorderStyle属性设为None,这样就可以根据自己的喜欢来设计界面.但这样窗体无法进行移动的.而且默认的窗体(FormBorderStyle=Sizab ...
- wcf契约随记
1.wcf契约分为:服务契约,操作契约,消息契约.数据契约 -------------------服务契约: [ServiceContract( Name = "name_IUser&quo ...
- NodeJs技术
我的NodeJs技术总结——第一篇 既然是我的技术总结,那就是以我的技术水平为基础的,写浅了大家不要笑话,如果有错误的地方还望指正. 这第一篇就谈谈NodeJs的一些编程细节吧. 1.遍历数组 f ...
- NUnit单元测试资料汇总
NUnit单元测试资料汇总 从安装到配置 首先到官网http://www.nunit.org/下载如下图的资料,安装NUnit-2.6.1.msi包. 然后挂在VS2010外部工具这个地方来使用,工具 ...
- CompareValues标签对Model中的属性进行验证
在Asp.Net MVC中实现CompareValues标签对Model中的属性进行验证 在Asp.Net MVC中可以用继承ValidationAttribute的方式,自定制实现Model两个 ...