POJ 1654 Area计算几何(解题报告)

ELK - CentOS7 安装 elasticsearch 7.17.5 elk elasticsearch 安装 阅读详情

Description

You are going to compute the area of a special kind of polygon. One vertex of the polygon is the origin of the orthogonal coordinate system. From this vertex, you may go step by step to the following vertexes of the polygon until back to the initial vertex. For each step you may go North, West, South or East with step length of 1 unit, or go Northwest, Northeast, Southwest or Southeast with step length of square root of 2.

For example, this is a legal polygon to be computed and its area is 2.5:

Input

The 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

For each polygon, print its area on a single line.

Sample Input

4
5
825
6725
6244865

Sample Output

0
0
0.5
2
 计算几何的经典题目,题目的意思是从一个点开始移动,可以移动八个方向,题目给出移动的方向
要求的是移动后构成的多边形的面积。这个题不记得叉积可以求面积了,衰,,,具体见代码吧,不难:

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
struct point 
{
	int x,y;
};
 
int det(point a,point b)
{//叉积求面积 
	return a.x*b.y-a.y*b.x;
}
//记录移动的坐标 
int stand[10][2]={{0,0},{-1,-1},{0,-1},{1,-1},{-1,0},{0,0},{1,0},{-1,1},{0,1},{1,1}};
int main()
{
	char a[1000001];
	int i,t,n,str;
	scanf("%d",&t);
	point pointone,pointtwo;
	while(t--)
	{
		long long s=0;
		scanf("%s",&a);
		str=strlen(a);
		if(str==1||str==2)//小于3 肯定是0; 
		{
			printf("0\n");
			continue;
		}
		for(i=0;i<str-1;i++)
		{
			if(i==0)
			{
				pointone.x=stand[a[i]-'0'][0];
				pointone.y=stand[a[i]-'0'][1];
			}
			else 
			{//开始求面积 
				pointtwo.x=pointone.x+stand[a[i]-'0'][0];
				pointtwo.y=pointone.y+stand[a[i]-'0'][1];
				s+=det(pointone,pointtwo);
				pointone=pointtwo;
			}
		}
		long long temp;
		if(s<0)
		{
			s=-s;
		}
		temp=s/2;
		if(temp*2==s)
		{
			printf("%lld\n",s/2);
		}
		else
		{
			printf("%lld.5\n",s/2);
		}
	}
	return 0;
}



从0到1构建数据分析AI Agent:数据采集、洞察生成与报告自动化 在企业数字化转型的今天,数据分析师80%的时间被消耗在重复取数、数据清洗、报表排版等低价值劳动上,真正用于深度业务洞察和决策支持的时间不足20%。本文将从核心概念、技术原理、代码实现、落地实践全维度,教你从0到1搭建一套完整的数据分析AI Agent系统,实现「用户用自然语言提需求→Agent自动采集多源数据→AI自动挖掘业务洞察→自动生成符合业务要求的多格式报告」的全链路自动化,平均可将需求响应速度从天级压缩到分钟级,释放70%以上的分析师人力成本。 阅读详情

相关推荐

论文解读--Phase Noise in FMCW Radar Systems

相位噪声是现代雷达、通信、光谱和计量系统的基本性能参数之一。本文提出了一种适用于FMCW雷达系统的相位噪声理论。导出了一个新的设计方程,用于确定雷达系统中允许的源相位噪声电平的最大界。分析了在传输延迟小于参考振荡器相干时间时,相干混频引起的非线性相位噪声去相关函数;讨论了在传输延迟大于参考振荡器相干时间时,目标响应的频谱展宽。提出了收发链中各子系统的影响,并讨论了一种新的ADC相位噪声模型。介绍了相位噪声建模技术,然后将锁相环频率合成器与低噪声频率合成器进行比较,以演示减少相位噪声边带以改善检测和跟踪性能。

奔袭的算法工程师 3766

poj 1654 Area(神题)

题目衔接:http://poj.org/problem?id=1654 Time Limit:1000MS Memory Limit:10000K Total Submissions:22770 Accepted:6146 Description You are going to compute the area of a special ...

lee371042的博客 284

基于DPABI和SPM12的任务态fMRI分析笔记1——预处理

前言 原理简介 预处理

Sophia2023的博客 1万+

poj 1654 Area (多边形求面积)

链接:http://poj.org/problem?id=1654 Area Time Limit:1000MS Memory Limit:10000K Total Submissions:14952 Accepted:4189 Description You are going to compute the area of...

weixin_30711917的博客 212

fMRI数据处理:从DICOM到NIFTI(下)

上一篇我们完成了对原始DICOM的数据整理,将其整理为了BIDS目录结构。作为从从DICOM到NIFTI的最后一篇,当然是介绍如何批量将DICOM格式转NIFTI格式啦!从DICOM到NIFTI系列就完成啦!撒花★,°.°★。从核磁机器把数据拷回来——到整理成BIDS格式——到批量转格式;我们fMRI数据处理的第一步就算是正式迈出去啦!接下来的内容,敬请期待吧~

weixin_44933894的博客 2078

深入解析车载以太网DoIP诊断:Wireshark实战TCP/UDS报文分析

本文深入解析车载以太网DoIP诊断,重点介绍如何利用Wireshark进行TCP/UDS报文实战分析。文章详细讲解了从以太网帧、IP帧、TCP段到DoIP协议及UDS服务的逐层拆解方法,并提供了使用Wireshark定位通信故障(如乱序、丢包、重传)的实用技巧,帮助工程师高效排查车载诊断网络问题。

c2d3e4f的博客 674

2018-07-29 计算几何

D  -- 计算特殊多边形面积 Description You are going to compute the area of a special kind of polygon. One vertex of the polygon is the origin of the orthogonal coordinate system. From this vertex, you may ...

zm_zsy的博客 280

Vue项目实战:5分钟搞定高德地图离线部署(附避坑指南)

本文详细介绍了在Vue项目中实现高德地图离线部署的完整方案。针对内网或网络隔离环境,通过获取并改造JSAPI文件、下载组织地图瓦片数据,并集成vue-amap组件,实现地图功能的本地化运行。文中提供了核心代码、避坑指南及性能优化建议,帮助开发者快速构建稳定可靠的离线地图应用。

data3的博客 935

D - Area解题报告

D - Area Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Description You are going to compute the area of a special kind of polygon. One ve

princeyuan的专栏 1031

手把手教你学Simulink--基于微电网的建模与仿真场景实例:独立运行模式下微电网的能量管理系统设计

本文详细介绍了使用Simulink对独立运行微电网能量管理系统进行建模与仿真的完整流程。主要包括:系统结构设计(分布式能源、储能系统、负荷等模块)、建模步骤(从创建项目到实现能量管理策略)、仿真设置与结果分析。通过建立基于规则的控制逻辑和优化调度算法,实现微电网的自主运行和能量优化管理。文章还提供了参数优化和多目标改进建议,为新能源和智能电网领域的研究与应用提供了实用指导。

MHD0815的博客 8582

7、布尔网络的基础定义

本文介绍了布尔网络的基础定义及其在系统生物学中的应用。布尔网络是一种描述复杂系统动态行为的数学模型,由布尔变量和布尔函数组成,能够模拟生物系统中基因调控、信号传导和细胞代谢等过程。文章详细阐述了布尔网络的基本结构、动力学特征(如状态转移图和吸引子),以及其在生物建模中的重要价值,并探讨了优化和简化技术(如Backward Boolean Equivalence)如何提升其计算效率。

yhn45678901的博客 262

POJ-1654 Area 解题报告

Description You are going to compute the area of a special kind of polygon. One vertex of the polygon is the origin of the orthogonal coordinate system. From this vertex, you may go step by step

我要变强!直到我的名字响彻天堂! 923

华为OD机试 - 魔法收积木 - 二进制(Java 新系统 200分)

华为OD机试 新系统 题库疯狂收录中,刷题。

学Java,找哪吒 442

POJ 1654 Area

POJ 1654 Area 很水的题。。 然后注意用上longlong,否则可能答案会不对。 #include #include #include #include #include #include using namespace std; #define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++) #define DOR(i,a,b) for(

utoppia is another word . 595

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

[poj 1654] Area {计算几何}

题目 http://poj.org/problem?id=1654 解题思路 原点为(0,0)(0,0)(0,0)时两点的叉积为(x1∗y2)−(x2∗y1)(x1*y2)-(x2*y1)(x1∗y2)−(x2∗y1) 因为在这道题中,多边形的面积一定是12的倍数\frac{1}{2}的倍数21​的倍数,所以可以直接用longlonglonglonglonglong来储存,毕竟在大数字面前dou...

Nowed 424

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

计算几何 POJ 1654 Area

Problem You are going to compute the area of a special kind of polygon. One vertex of the polygon is the origin of the orthogonal coordinate system. From this vertex, you may go step by step to the fo...

FrankDura的博客 536

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

poj1654 Area

题目描述: vjudge POJ 题解: 本以为是水题结果是神题 计算几何求多边形面积。 考虑到结果一定是整数或者整数/2,我们应该用long long 来存…… 用double会死…… 还有日常只能用c++编译器,不能用g++。 还有用abs会莫名ce,要手写。 代码: #include<cmath> #include<cstdio&g...

a6t2007的博客 190

POJ 1654 Area(多边形面积)

POJ 1654 Area(多边形面积) http://poj.org/problem?id=1654 题意:        在一个网格中,你当前在起始点,然后给你一些数字,每个数字表示你网当前位置的8个方向走一步.然后你到了下一个网格点了,就这样让你走出一个多边形,要你输出该多边形的面积. 题目保证最后一步是回到原点,且保证能形成多边形. 分析:        82 6 4 : 上,

code 1067

POJ1654 Area【多边形的面积】

POJ1654Area http://poj.org/problem?id=1654 题意 在一个网格中,你当前在起始点,然后给你一些数字,每个数字表示你往当前位置的8个方向走一个单位或根号2个单位(斜线...

逐梦者 387

【Poj 1654】Area【计算几何】【叉积】

解题思路 题目大意:一个坐标系,从原点开始走,然后1-4分别代表,向右下走,向右走,向右上走,向下走,5代表回到原点,6-9代表,向上走,向左下走,向左走,向左上走。(看翻译直接无限WA),给出一串包含1-9的字符串,问你这些点所围成的面积 把每个数字对应横纵坐标的变化量预处理出来(就像广搜的dx,dy一样) dx[10]= {0,1,1,1,0,0,0,-1,-1,-1},dy[10]= {0,-1,0,1,-1,0,1,-1,0,1}; 这样我们就能先求出每个点的坐标,而他们又是有序的且一定能...

在人间贩卖声音 208

POJ 1654 Area(简单计算几何)

Area Time Limit: 1000MS Memory Limit: 10000K Description You are going to compute the area of a special kind of polygon. One vertex of the polygon is the origin of the orthogonal coordinate s...

苟为蒟蒻又何妨 361

Area_poj1654_计算几何

DescriptionYou are going to compute the area of a special kind of polygon. One vertex of the polygon is the origin of the orthogonal coordinate system. From this vertex, you may go step by step to the

olahiuj的博客 552

【计算几何】poj 1654 Area

计算凸包面积,非常基础的一道计算几何题目,精度问题上比较烦人,需要转换成long long来输出最终结果。 #include #include #include using namespace std; const int dir_x[]={0,-1,0,1,-1,0,1,-1,0,1}; const int dir_y[]={0,-1,-1,-1,0,0,0,1,1,1}; struct P

BananaTree 586

POJ 1654 Area [多边形面积]

题目链接:http://poj.org/problem?id=1654 题目的意思

1173
上一篇: POJ 3528 Ultimate Weapon三维凸包(解题报告)
下一篇: ZOJ 1648 Circuit Board计算几何(解题报告)
CSUST_ACM
博客等级 码龄15年 42粉丝 127原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值