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 ...
随机推荐
- Hadoop-2.4.1学习之Writable及事实上现
Hadoop基于DataInput和DataOutput实现了简单.高效的序列化协议,而Writable接口定义了Hadoop序列化的方法,MapReduce框架中的不论什么键值类型都实现了该接口,比 ...
- Winform: use the WebBrowser to display XML with xslt, xml, xslt 转 html 字符串
原文:Winform: use the WebBrowser to display XML with xslt, xml, xslt 转 html 字符串 声明xml字符串: string xml = ...
- nodeJS起步 1
nodeJS起步 -- (1) 先来简单介绍nodeJS 我们知道JavaScript是运行在浏览器中的,浏览器为它提供了一个上下文(context),从而让JavaScript得以解析执行. nod ...
- [Unity3D]Unity3D游戏开发Android内嵌视图Unity查看
---------------------------------------------------------------------------------------------------- ...
- Delphi三层网络架构代码实现
Delphi三层网络架构代码实现 1 .三层网络的概念 三层架构(3-tier architecture) 通常意义上的三层架构就是将整个业务应用划分为: 表现层(UI).业务逻辑层(BLL).数据访 ...
- PHP激活用户注册验证邮箱
本文将结合实例介绍如何使用PHP+Mysql完成注册帐号.发送激活邮件.验证激活帐号.处理URL链接过期的功能. 注册邮箱激活流程 <ul class='ul_demo''> <li ...
- android rawquery和query对照
Cursor cursor = db.rawQuery("select name from *** where id=? ", new String[]{"1" ...
- jquery背景动画插件使用
在网页制作动画特效的时候,有时候想通过背景插入图片,然后通过控制背景显示的位置来实现一些动画效果,这样就不用使用绝对定位控制left和top来实现动画效果!但是jquery本身的动画函数是不支持背景动 ...
- 【从0开始Tornado网站】主页登录和显示的最新文章
日志首页只能放置在它,这里的美,该<form>使用bootstrap的form-inline修改后的类,例如以下列方式: 前台代码例如以下: {%extends 'main.html'%} ...
- Extjs中GridPanel的各个属性与方法
1.Ext.grid.GridPanel 主要配置项: store:表格的数据集 columns:表格列模式的配置数组,可自动创建ColumnModel列模式 autoExpandColumn:自动充 ...