蓝桥杯练习系统(算法训练)ALGO-946 Q神的足球赛
资源限制
内存限制:256.0MB C/C++时间限制:1.0s Java时间限制:3.0s Python时间限制:5.0s
问题描述
足球赛上,只见Q神如闪电般的速度带球时而左,时而右,时而前,时而后,时而上,时而下……等等,有什么奇怪的东西混进去了?假设Q神力量可以突破地心引力,他在一个三维空间里面可以沿着直角坐标系的坐标轴方向前进。告诉你他的每一次转的方向以及前进的距离,请你回答他最后在哪个位置,面朝那一个方向。假设他一开始在(0,0,0),面朝x轴的正方向。
输入格式
多组输入数据。
每组第一行是一个整数n。接下来n行每行一个字符表示方向,接着一个整数表示前进距离。其中,f(forward)表示继续前进,方向不变;b(back)表示向后转;l(left)表示向左转;r(right)表示像右转;u(up)表示向上;d(表示向下)。如图示。

输出格式
对于每一组数据,输出Q神的坐标和他的朝向。其中:左手系的x正方向、y正方向、z正方向分别位0、1、2,对应的负方向分别为3、4、5.

样例输入
6 l 10 r 11 u 12 d 13 f 14 b 15
样例输出
23 -10 12 3
数据规模和约定
数据组数不超过10组,n《=200 ,每次移动距离不超过100
#include<iostream>
using namespace std;
int next_face(int &face,int &foot,char orient){if(face==0){if(foot==5){if(orient=='f'){face=0;}else if(orient=='b'){face=3;}else if(orient=='l'){face=4;}else if(orient=='r'){face=1;}else if(orient=='u'){face=2;foot=0;}else if(orient=='d'){face=5;foot=3;}}if(foot==1){if(orient=='f'){face=0;}else if(orient=='b'){face=3;}else if(orient=='l'){face=5;}else if(orient=='r'){face=2;}else if(orient=='u'){face=4;foot=0;}else if(orient=='d'){face=1;foot=3;}}if(foot==2){if(orient=='f'){face=0;}else if(orient=='b'){face=3;}else if(orient=='l'){face=1;}else if(orient=='r'){face=4;}else if(orient=='u'){face=5;foot=0;}else if(orient=='d'){face=2;foot=3;}}if(foot==4){if(orient=='f'){face=0;}else if(orient=='b'){face=3;}else if(orient=='l'){face=2;}else if(orient=='r'){face=5;}else if(orient=='u'){face=1;foot=0;}else if(orient=='d'){face=4;foot=3;}}}else if(face==1){if(foot==5){if(orient=='f'){face=1;}else if(orient=='b'){face=4;}else if(orient=='l'){face=0;}else if(orient=='r'){face=3;}else if(orient=='u'){face=2;foot=1;}else if(orient=='d'){face=5;foot=4;}}if(foot==3){if(orient=='f'){face=1;}else if(orient=='b'){face=4;}else if(orient=='l'){face=5;}else if(orient=='r'){face=2;}else if(orient=='u'){face=0;foot=1;}else if(orient=='d'){face=3;foot=4;}}if(foot==2){if(orient=='f'){face=1;}else if(orient=='b'){face=4;}else if(orient=='l'){face=3;}else if(orient=='r'){face=0;}else if(orient=='u'){face=5;foot=1;}else if(orient=='d'){face=2;foot=4;}}if(foot==0){if(orient=='f'){face=1;}else if(orient=='b'){face=4;}else if(orient=='l'){face=2;}else if(orient=='r'){face=5;}else if(orient=='u'){face=3;foot=1;}else if(orient=='d'){face=0;foot=4;}}}else if(face==2){if(foot==4){if(orient=='f'){face=2;}else if(orient=='b'){face=5;}else if(orient=='l'){face=3;}else if(orient=='r'){face=0;}else if(orient=='u'){face=1;foot=2;}else if(orient=='d'){face=4;foot=5;}}if(foot==3){if(orient=='f'){face=2;}else if(orient=='b'){face=5;}else if(orient=='l'){face=1;}else if(orient=='r'){face=4;}else if(orient=='u'){face=0;foot=2;}else if(orient=='d'){face=3;foot=5;}}if(foot==1){if(orient=='f'){face=2;}else if(orient=='b'){face=5;}else if(orient=='l'){face=0;}else if(orient=='r'){face=3;}else if(orient=='u'){face=4;foot=2;}else if(orient=='d'){face=1;foot=5;}}if(foot==0){if(orient=='f'){face=2;}else if(orient=='b'){face=5;}else if(orient=='l'){face=4;}else if(orient=='r'){face=1;}else if(orient=='u'){face=3;foot=2;}else if(orient=='d'){face=0;foot=5;}}}else if(face==3){if(foot==5){if(orient=='f'){face=3;}else if(orient=='b'){face=0;}else if(orient=='l'){face=1;}else if(orient=='r'){face=4;}else if(orient=='u'){face=2;foot=3;}else if(orient=='d'){face=5;foot=0;}}if(foot==1){if(orient=='f'){face=3;}else if(orient=='b'){face=0;}else if(orient=='l'){face=2;}else if(orient=='r'){face=5;}else if(orient=='u'){face=4;foot=3;}else if(orient=='d'){face=1;foot=0;}}if(foot==2){if(orient=='f'){face=3;}else if(orient=='b'){face=0;}else if(orient=='l'){face=4;}else if(orient=='r'){face=1;}else if(orient=='u'){face=5;foot=3;}else if(orient=='d'){face=2;foot=0;}}if(foot==4){if(orient=='f'){face=3;}else if(orient=='b'){face=0;}else if(orient=='l'){face=5;}else if(orient=='r'){face=2;}else if(orient=='u'){face=1;foot=3;}else if(orient=='d'){face=4;foot=0;}}}else if(face==4){if(foot==5){if(orient=='f'){face=4;}else if(orient=='b'){face=1;}else if(orient=='l'){face=3;}else if(orient=='r'){face=0;}else if(orient=='u'){face=2;foot=4;}else if(orient=='d'){face=5;foot=1;}}if(foot==3){if(orient=='f'){face=4;}else if(orient=='b'){face=1;}else if(orient=='l'){face=2;}else if(orient=='r'){face=5;}else if(orient=='u'){face=0;foot=4;}else if(orient=='d'){face=3;foot=1;}}if(foot==2){if(orient=='f'){face=4;}else if(orient=='b'){face=1;}else if(orient=='l'){face=0;}else if(orient=='r'){face=3;}else if(orient=='u'){face=5;foot=4;}else if(orient=='d'){face=2;foot=1;}}if(foot==0){if(orient=='f'){face=4;}else if(orient=='b'){face=1;}else if(orient=='l'){face=5;}else if(orient=='r'){face=2;}else if(orient=='u'){face=3;foot=4;}else if(orient=='d'){face=0;foot=1;}}}else if(face==5){if(foot==1){if(orient=='f'){face=5;}else if(orient=='b'){face=2;}else if(orient=='l'){face=3;}else if(orient=='r'){face=0;}else if(orient=='u'){face=4;foot=5;}else if(orient=='d'){face=1;foot=2;}}if(foot==3){if(orient=='f'){face=5;}else if(orient=='b'){face=2;}else if(orient=='l'){face=4;}else if(orient=='r'){face=1;}else if(orient=='u'){face=0;foot=5;}else if(orient=='d'){face=3;foot=2;}}if(foot==4){if(orient=='f'){face=5;}else if(orient=='b'){face=2;}else if(orient=='l'){face=0;}else if(orient=='r'){face=3;}else if(orient=='u'){face=1;foot=5;}else if(orient=='d'){face=4;foot=2;}}if(foot==0){if(orient=='f'){face=5;}else if(orient=='b'){face=2;}else if(orient=='l'){face=1;}else if(orient=='r'){face=4;}else if(orient=='u'){face=3;foot=5;}else if(orient=='d'){face=0;foot=2;}}}
}
int main(){int n;while(cin>>n){int x=0,y=0,z=0;//最开始时的坐标int face=0;//脸的朝向 int foot=5;//脚的站位 for(int i=0;i<n;i++){char orient;int num;cin>>orient>>num;next_face(face,foot,orient);if(face==0){x+=num;}else if(face==1){y+=num;}else if(face==2){z+=num;}else if(face==3){x-=num;}else if(face==4){y-=num;}else if(face==5){z-=num;}} cout<<x<<" "<<y<<" "<<z<<" "<<face<<" "<<endl;}return 0;
}

思路:需要知道Q神的脸的朝向、脚的站位(头指向脚的方向)才能确定Q神的位置。已知脸的朝向,可能有4个站位。
例如:初始位置:脸的朝向为0,脚的站位为5

相关文章:
蓝桥杯练习系统(算法训练)ALGO-946 Q神的足球赛
资源限制 内存限制:256.0MB C/C时间限制:1.0s Java时间限制:3.0s Python时间限制:5.0s 问题描述 足球赛上,只见Q神如闪电般的速度带球时而左,时而右,时而前,时而后ÿ…...
【Android】Kotlin学习之Kotlin方法的声明和传参
方法声明 普通类的方法 静态类的方法 不需要构建实例对象, 可以通过类名直接访问静态方法 : NumUtil.double(1) companion object 伴生类的方法 使用companion object 在普通类里定义静态方法 参数 括号内传入方法 : 当参数是方法时, 并且是最后一个参数 , 可以使用括号外…...
微信小程序 17:小程序使用 npm 包和组件应用
目前,小程序中已经支持实用 npm 安装第三方包,从而提高小程序的开发效率,但是在小程序中使用 npm 包有三个限制: 不支持 Node.js内置库的包不支持依赖于浏览器内置对象的包不支持依赖于 C插件的包 Vant Weapp Vant Weapp是有赞…...
【mysql篇】执行delete删除大量数据后,磁盘未清空,为什么?
目录 迁移脚本删除数据以及备份数据 解决方法OPTIMIZE TABLE二进制日志按月生成数据 最近某个项目虽说用户量不大,但是,单表的数据量越来越大,mysql一般单表超过千万级别后,性能直线下降,所以利用shardingphere按月做了…...
【Qt 学习笔记】Qt常用控件 | 多元素控件 | Tree Widget的说明及介绍
博客主页:Duck Bro 博客主页系列专栏:Qt 专栏关注博主,后期持续更新系列文章如果有错误感谢请大家批评指出,及时修改感谢大家点赞👍收藏⭐评论✍ Qt常用控件 | 多元素控件 | Tree Widget的说明及介绍 文章编号&#x…...
在Mars3d实现cesium的ImageryLayer自定义瓦片的层级与原点
需要自定义瓦片层级和原点,所以需要自己写第三方图层,但是之前写的很多方法,图层控制和显隐以及透明度,需要跟之前的交互一直,改动量太大的话不划算,所以直接看Mars3d的layer基类,把重写的image…...
logback日志持久化
1、问题描述 使用logback持久化记录日志。 2、我的代码 logback是Springboot框架里自带的,所以只要引入“spring-boot-starter”就行了。无需额外引入logback依赖。 pom.xml <?xml version"1.0" encoding"UTF-8"?> <project xmlns&…...
函数原型(Function Prototype)、函数定义(Function Definition)和函数声明(Function Declaration)
函数原型(Function Prototype)、函数定义(Function Definition)和函数声明(Function Declaration)在C和C等编程语言中扮演着不同的角色,但它们有时在概念上可能会有些重叠。下面是它们之间的主要…...
Go有无缓冲channel的区别
无缓冲的channel channel的默认类型就是无缓冲的。当一个数据被发送到无缓冲的channel中,发送操作会被阻塞,知道有另一个goroutine从这个channel中接收这个数据。同样,当试图从一个无缓冲的channel中接收数据时,如果没有数据可以…...
【全开源】Fastflow工作流系统(源码搭建/上线/运营/售后/维护更新)
一款基于FastAdminThinkPHP开发的可视化工作流程审批插件,帮助用户基于企业业务模式和管理模式自行定义所需的各种流程应用,快速构建企业自身的流程管控体系,快速融合至企业协同OA办公系统。 提供全部无加密服务端源码和前端源代码࿰…...
超越传统游戏:生成式人工智能对游戏的变革性影响
人工智能(AI)在游戏中的应用 游戏产业是一个充满活力、不断发展的领域,人工智能(AI)的融入对其产生了重大影响。这一技术进步彻底改变了游戏的开发、玩法和体验方式。本文分析的重点是传统人工智能和生成式人工智能在游…...
SpringCloud微服务之Eureka、Ribbon、Nacos详解
SpringCloud微服务之Eureka、Ribbon、Nacos详解 1、认识微服务1.1、单体架构1.2、分布式架构1.3、微服务1.4、SpringCloud 2、服务拆分与远程调用2.1、服务拆分的原则2.2、服务拆分示例2.2、提供者与消费者 3、Eureka注册中心3.1、Eureka的结构和作用3.2、搭建eureka-server3.2…...
五角钱的程序员 | Kafka 是什么?
本文来源公众号“五角钱的程序员”,仅用于学术分享,侵权删,干货满满。 原文链接:Kafka 是什么? 你是一个程序员,假设你维护了两个服务 A 和 B。B 服务每秒只能处理 100 个消息,但 A 服务却每秒…...
C++中合成的默认构造函数的访问权限
问题 我们知道,在C中,如果没有为一个类显式定义构造函数,那么编译器会为我们隐式地定义一个默认构造函数。那么,你有没有想过,这个隐式定义的默认构造函数(合成的默认构造函数)的访问权限是什么…...
【前端】桌面版docker并部署前端项目
环境 win10专业版 2004 , 需科学 官网下载安装包并安装4.29.0版本 终端输入 wsl --installdocker桌面版和模拟器只能选一个,不然一直转圈圈 镜像配置加速,在settings—>docker engine下 {"builder": {"gc": {"defaultKee…...
发布GPT-5的方式可能会与以往不同;开源vocode使用 AI 自动拨打电话;开源gpt智能对话客服工具;AI自动写提示词
✨ 1: vocode 用AI通过声音与用户进行实时交流 Vocode是一个旨在帮助开发者快速构建基于声音的大型语言模型(LLM)应用程序的开源库。简单来说,如果你想要开发一个能够通过声音与用户进行实时交流的应用,比如电话机器人、语音助手…...
Linux 作业管理 (bg, fg, jobs, kill)
bg 和 fg 是用来管理作业(在 Unix/Linux 命令行下运行的进程)的命令。 1. bg 命令 bg 命令用于将作业(job)放到后台运行。当你在终端中运行一个命令或程序时,它会占用当前终端的控制,如果你想让这个任务在…...
springboot Redis 支持星号(*) 包括注解@Cache
通过自定义CacheManager Bean来实现 bean Autowiredprivate RedisConnectionFactory redisConnectionFactory;/*** 管理缓存** return*///缓存管理器PrimaryBeanOverridepublic CacheManager cacheManager() {// 使用自定义的缓存配置初始化一个cacheManagerreturn new Custom…...
2023.5.12 第43周周报
学习时间:2023.5.5-2023.5.12 学习内容: 1、answer question: img: 看到有论文说应该让图像和文本的潜在嵌入具有相似和合理的数值范围【-2,2】 调试发现模型的文本图像的潜在嵌入虽然符合,但相差较大。 在将文本和…...
JavaEE 多线程详细讲解(2)
1.线程不安全分析 (1)线程不安全的主要原因就是,系统的抢占式执行,对于内核设计者来说,这是非常方便的一个执行方式,但是这却却导致线程不安全的问题,也有不抢占执行的系统,但是这种…...
【WiFi帧结构】
文章目录 帧结构MAC头部管理帧 帧结构 Wi-Fi的帧分为三部分组成:MAC头部frame bodyFCS,其中MAC是固定格式的,frame body是可变长度。 MAC头部有frame control,duration,address1,address2,addre…...
ssc377d修改flash分区大小
1、flash的分区默认分配16M、 / # df -h Filesystem Size Used Available Use% Mounted on /dev/root 1.9M 1.9M 0 100% / /dev/mtdblock4 3.0M...
SCAU期末笔记 - 数据分析与数据挖掘题库解析
这门怎么题库答案不全啊日 来简单学一下子来 一、选择题(可多选) 将原始数据进行集成、变换、维度规约、数值规约是在以下哪个步骤的任务?(C) A. 频繁模式挖掘 B.分类和预测 C.数据预处理 D.数据流挖掘 A. 频繁模式挖掘:专注于发现数据中…...
python如何将word的doc另存为docx
将 DOCX 文件另存为 DOCX 格式(Python 实现) 在 Python 中,你可以使用 python-docx 库来操作 Word 文档。不过需要注意的是,.doc 是旧的 Word 格式,而 .docx 是新的基于 XML 的格式。python-docx 只能处理 .docx 格式…...
JDK 17 新特性
#JDK 17 新特性 /**************** 文本块 *****************/ python/scala中早就支持,不稀奇 String json “”" { “name”: “Java”, “version”: 17 } “”"; /**************** Switch 语句 -> 表达式 *****************/ 挺好的ÿ…...
css3笔记 (1) 自用
outline: none 用于移除元素获得焦点时默认的轮廓线 broder:0 用于移除边框 font-size:0 用于设置字体不显示 list-style: none 消除<li> 标签默认样式 margin: xx auto 版心居中 width:100% 通栏 vertical-align 作用于行内元素 / 表格单元格ÿ…...
Device Mapper 机制
Device Mapper 机制详解 Device Mapper(简称 DM)是 Linux 内核中的一套通用块设备映射框架,为 LVM、加密磁盘、RAID 等提供底层支持。本文将详细介绍 Device Mapper 的原理、实现、内核配置、常用工具、操作测试流程,并配以详细的…...
BLEU评分:机器翻译质量评估的黄金标准
BLEU评分:机器翻译质量评估的黄金标准 1. 引言 在自然语言处理(NLP)领域,衡量一个机器翻译模型的性能至关重要。BLEU (Bilingual Evaluation Understudy) 作为一种自动化评估指标,自2002年由IBM的Kishore Papineni等人提出以来,…...
GraphQL 实战篇:Apollo Client 配置与缓存
GraphQL 实战篇:Apollo Client 配置与缓存 上一篇:GraphQL 入门篇:基础查询语法 依旧和上一篇的笔记一样,主实操,没啥过多的细节讲解,代码具体在: https://github.com/GoldenaArcher/graphql…...
【实施指南】Android客户端HTTPS双向认证实施指南
🔐 一、所需准备材料 证书文件(6类核心文件) 类型 格式 作用 Android端要求 CA根证书 .crt/.pem 验证服务器/客户端证书合法性 需预置到Android信任库 服务器证书 .crt 服务器身份证明 客户端需持有以验证服务器 客户端证书 .crt 客户端身份…...
