POJ1065 Area
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 18499 | Accepted: 5094 |
Description
For example, this is a legal polygon to be computed and its area is 2.5:

Input
first line of input is an integer t (1 <= t <= 20), the number of
the test polygons. Each of the following lines contains a string
composed of digits 1-9 describing how the polygon is formed by walking
from the origin. Here 8, 2, 6 and 4 represent North, South, East and
West, while 9, 7, 3 and 1 denote Northeast, Northwest, Southeast and
Southwest respectively. Number 5 only appears at the end of the sequence
indicating the stop of walking. You may assume that the input polygon
is valid which means that the endpoint is always the start point and the
sides of the polygon are not cross to each other.Each line may contain
up to 1000000 digits.
Output
Sample Input
4
5
825
6725
6244865
Sample Output
0
0
0.5
2
Source
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int mx[]={,,,,,,,-,-,-},
my[]={,-,,,-,,,-,,};
long long s;
int x,y;
long long area(int x1,int y1,int x2,int y2){//叉积求面积
return x1*y2-x2*y1; }
int main(){
int T;
scanf("%d\n",&T);
while(T--){
char str[];
scanf("%s",str);
s=;
x=;y=;
int len=strlen(str);
//
if(len<){
printf("0\n");
continue;
}
//
for(int i=;i<len;i++){
int num=str[i]-'';
int nowx=x+mx[num];
int nowy=y+my[num];
s+=area(x,y,nowx,nowy);
x=nowx;
y=nowy;
}
if(s<)s=-s;
if(s&){
printf("%lld.5\n",s/);
}
else printf("%lld\n",s/);
}
return ;
}
POJ1065 Area的更多相关文章
- [转]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 ...
- ASP.NET MVC系列:Area
1. Area简介 ASP.NET MVC Area机制构建项目,可以将相对独立的功能模块切割划分,降低项目的耦合度. 2. Area设置Routing 新建Admin Area后,自动创建Admin ...
- Web API项目中使用Area对业务进行分类管理
在之前开发的很多Web API项目中,为了方便以及快速开发,往往把整个Web API的控制器放在基目录的Controllers目录中,但随着业务越来越复杂,这样Controllers目录中的文件就增加 ...
- MVC View中获取action、controller、area名称
获取控制器名称: ViewContext.RouteData.Values["controller"].ToString(); 获取Action名称: ViewContext.Ro ...
- [LeetCode] Rectangle Area 矩形面积
Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...
- 如何在Linux上使用文件作为内存交换区(Swap Area)
交换区域(Swap Area)有什么作用? 交换分区是操作系统在内存不足(或内存较低)时的一种补充.通俗的说,如果说内存是汽油,内存条就相当于油箱,交换区域则相当于备用油箱. Ubuntu Linux ...
- MVC 添加Area
在MVC项目中经常会使用到Area来分开不同的模块让项目结构更加的清晰. 步骤如下: 项目 –> 添加 -> 区域 ( Area ) 输入 Admin 添加成功后 Area包含: 创建一个 ...
- ASP.NET MVC 设置Area中 Controller 的方法 默认启动页
MVC中通常分区域编程,互不干扰,如果需要设置某个区域下面的某个控制器下面的某个方法为默认启动页的话,直接修改项目的路由如下: public static void RegisterRoutes(Ro ...
- [ASP.NET MVC 小牛之路]08 - Area 使用
ASP.NET MVC允许使用 Area(区域)来组织Web应用程序,每个Area代表应用程序的不同功能模块.这对于大的工程非常有用,Area 使每个功能模块都有各自的文件夹,文件夹中有自己的Cont ...
随机推荐
- UINavagationController
如何防止navigation多次push一个页面?有时候网慢,点了一下没反应,用户可能就多点几下,这时候会打开好几个一样的页面: 写了一个navigation基类,重写了push方法:传进来要push ...
- /etc/profile和~/.bash_profile的区别
/etc/profile是全局的,是私有的 /etc/profile用于整个系统所有用户, ~/.bash_profile, ~/.profile和~/.bashrc 用于各个用户,这里的" ...
- ESLint 检查代码质量
利用 ESLint 检查代码质量 其实很早的时候就想尝试 ESLint 了,但是很多次都是玩了一下就觉得这东西巨复杂,一执行检查就是满屏的error,简直是不堪入目,遂放弃.直到某天终于下定决心深入看 ...
- cobbler
原理: http://www.cnblogs.com/mchina/p/centos-pxe-kickstart-auto-install-os.html 一键脚本 http://tshare365. ...
- ASP.NET中进行消息处理(MSMQ) 二
在我上一篇文章<ASP.NET中进行消息处理(MSMQ)一>里对MSMQ做了个通俗的介绍,最后以发送普通文本消息和复杂的对象消息为例介绍了消息队列的使用. 本文在此基础上继续介绍MSMQ的 ...
- 在coding上添加ssh-key
第一步:检查有没有ssh-key 第二步:生成ssh-key 第三步:添加到coding上或者Github上. ls -al ~/.ssh ssh-keygen -t rsa -C "you ...
- java <? super Fruit>与<? extends Fruit>
package Test2016; import java.util.ArrayList; import java.util.List; public class Test2016 { public ...
- 解决jquery $符号的冲突
今天做项目的时候,写了一个ajax提交的js函数,然后在js调试的时候,提示发现 $.ajax ,前面的$ 符号不见了,通过网上搜索找到了下面的解决方法 jQuery中需要用到$符号,如果其他js库也 ...
- sql server 2008 基础知识
一.配置管理器 1.管理服务 使用配置管理器可以启动.停止.重新启动.继续或暂停服务. 服务器和客户端网络协议 2.SQLSMS 简介:SQLSMS是一个集成环境,用于访问.配置.管理和开发SQL ...
- ModernUI教程:第一个ModernUI应用(手动编写)
这篇文章带着我们从头开始创建一个Modern UI应用.有关采用项目模板和项模板创建Modern UI应用请参看 第一个ModernUI应用(采用项目模板). 1:获取最新的ModernUI发布并解 ...