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 ...
随机推荐
- linux下删除文件名乱码文件
linux下通过rm命令来删除文件,但是如果要删除文件名乱码的文件,就不能直接使用rm命令了,因为压根就无法输出文件名来.不过借助find命令可以实现对其删除.在linux下对于每个文件都一个对应的不 ...
- python-基础案例
范例一: 练习:元素分类 有如下值集合 [11,22,33,44,55,66,77,88,99,90...],将所有大于 66 的值保存至字典的第一个key中,将小于 66 的值保存至第二个key的值 ...
- CSS 布局调试工具
说是工具其实只是一段 Javascript 代码,但非常实用,它会给页面里所有的 DOM 元素添加一个 1px 的描边(outline),方便我们在调试 CSS 过程中分析.排查问题. 先来看看代码, ...
- POJ 3461 Oulipo
E - Oulipo Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- 【转】【WPF】WriteableBitmap应用及图片数据格式转换
使用 WriteableBitmap 类基于每个框架来更新和呈现位图.这对于生成算法内容(如分形图像)和数据可视化(如音乐可视化工具)很有用. WriteableBitmap 类使用两个缓冲区.“后台 ...
- Nginx+UWSGI+Django配置全过程
重度参阅 原理+实战http://zhou123.blog.51cto.com/4355617/1688434 原理http://www.cnblogs.com/fnng/p/5268633.html ...
- C语言 预处理三(条件编译--#if)
//#if 条件编译 //一般用于产品各个版本的语言包 #include<stdio.h> #include<stdlib.h> //#都是预处理指令,条件表达式必须在预处理里 ...
- HttpClient通过Post上传文件(转)
在之前一段的项目中,使用Java模仿Http Post方式发送参数以及文件,单纯的传递参数或者文件可以使用URLConnection进行相应的处理. 但是项目中涉及到既要传递普通参数,也要传递多个文件 ...
- getLovParameter
else if (pageContext.isLovEvent()) { StHelper.handleLovEvent(pageContext, webBean); } public static ...
- php基础29:打开目录
<?php //1.打开一个目录 $dir = opendir("E:\AppServ\www\php"); //读取目录,使用一个循环来读出 while (!!$file= ...