PAT甲级1031,1032解题报告

一个基于ZYNQ、AXI接口的PL端卷积加速器,可由PS端调用(附Github源码) 一个基于ZYNQ,AXI接口的PL端卷积加速器,可由PS端调用开发板型号:Zynq-7000 SoC XC7Z305 FPGA开发平台:Vivado 2019.1;Github源码链接:https://github.com/CY0807/ZYNQ_PL_CONV_ACC。 阅读详情

1031 Hello World for U (20 分)

Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as:

h  d
e  l
l  r
lowo

That is, the characters must be printed in the original order, starting top-down from the left vertical line with n​1​​ characters, then left to right along the bottom line with n​2​​ characters, and finally bottom-up along the vertical line with n​3​​ characters. And more, we would like U to be as squared as possible -- that is, it must be satisfied that n​1​​=n​3​​=max { k | k≤n​2​​ for all 3≤n​2​​≤N } with n​1​​+n​2​​+n​3​​−2=N.

Input Specification:

Each input file contains one test case. Each case contains one string with no less than 5 and no more than 80 characters in a line. The string contains no white space.

Output Specification:

For each test case, print the input string in the shape of U as specified in the description.

Sample Input:

helloworld!

Sample Output:

h   !
e   d
l   l
lowor

题目大意:给一个字符串,按一定格式输出一下。

解题思路:关键在于确定有几行。然后题目告诉了一个等式两个不等式。。这个时候我们只要线性规划一下就可以得出几行了,然后就是输出一下,很水。

代码如下

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<time.h>
#include<math.h>
#include<set>
#include<map>
#include<list>
#include<climits>
#include<queue>
using namespace std;
int main()
{
	string cur;
	getline(cin, cur);
	int len = cur.size();
	int k;
	if (len <= 7) {
		k = (len - 1) / 2;
	}
	else {
		k = (len + 2) / 3;
	}
	for (int i = 0; i < k; i++) {
			if (i != k - 1) {
				cout << cur[i];
				for (int j = 0; j < len  - 2 * k; j++) {
					cout << " ";
				}
				cout << cur[len - i - 1] << endl;
			}
			else {
				for (int j = 0; j < len-2*k+2; j++) {
					cout << cur[j+k-1];
				}
				cout << endl;
			}
	}
	return 0;
}

1032 Sharing (25 分)

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, loading and being are stored as showed in Figure 1.

fig.jpg

Figure 1

You are supposed to find the starting position of the common suffix (e.g. the position of i in Figure 1).

Input Specification:

Each input file contains one test case. For each case, the first line contains two addresses of nodes and a positive N (≤10​5​​), where the two addresses are the addresses of the first nodes of the two words, and N is the total number of nodes. The address of a node is a 5-digit positive integer, and NULL is represented by −1.

Then N lines follow, each describes a node in the format:

Address Data Next

whereAddress is the position of the node, Data is the letter contained by this node which is an English letter chosen from { a-z, A-Z }, and Next is the position of the next node.

Output Specification:

For each case, simply output the 5-digit starting position of the common suffix. If the two words have no common suffix, output -1 instead.

Sample Input 1:

11111 22222 9
67890 i 00002
00010 a 12345
00003 g -1
12345 D 67890
00002 n 00003
22222 B 23456
11111 L 00001
23456 e 67890
00001 o 00010

Sample Output 1:

67890

Sample Input 2:

00001 00002 4
00001 a 10001
10001 s -1
00002 a 10002
10002 t -1

Sample Output 2:

-1

题目大意:类似双向链表,有两条,找这两条的公共部分的开始点。

解题思路:很水的开两个数组,一个记录每个节点的下一个节点地址,另一个记录一下是否访问过。

把第一个单词遍历一遍,把访问过的节点全部标记一下,然后第二个节点开始遍历,如果遇到访问过的,就结束遍历。如果没有,就继续。最后如果是-1,那么就是没有公共部分,如果不是-1那么就是目前的节点。

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<time.h>
#include<math.h>
#include<set>
#include<list>
#include<climits>
#include<queue>
#include<cstring>
using namespace std;
int map[100005];
bool vist[100005];
int main()
{
	int a1, a2, n;
	cin >> a1 >> a2 >> n;
	memset(map,-1,sizeof(map));
	memset(vist, false, sizeof(vist));
	for (int i = 0; i < n; i++) {
		int a, b;
		char c;
		cin >> a >> c >> b;
		map[a] = b;
	}
	int address = a1;
	while (address != -1) {
		vist[address] = 1;
		address = map[address];
	}
 address = a2;
	while (address != -1 && !vist[address]) {
		address = map[address];
	}
	if (address == -1)cout << -1<<endl;
	else
		printf("%05d\n", address);
	return 0;
}

 

CMMI评审 CMMI到底是什么? 阅读详情

相关推荐

深入RK3588嵌入式Linux开发:uboot源码定制化移植实战

本文详细介绍了RK3588嵌入式Linux开发中,如何绕过庞大的官方SDK,从官方仓库获取纯净U-Boot源码并进行定制化移植的完整实战流程。内容包括编译环境搭建、交叉工具链配置、源码结构解析、设备树(Device Tree)修改、环境变量定制、编译脚本编写以及常见问题调试技巧,旨在帮助开发者深入理解系统引导过程,掌握为定制硬件适配U-Boot的核心技能。

weixin_29169505的博客 434

PAT 1031 Hello World for U python解法

1031 Hello World for U (20 分) Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l l r lowo That is, ...

qq_36936510的博客 384

抖音直播“卡黑屏”技术解析:从实现原理到平台风控与合规运营

在直播技术领域,视频流推送与实时互动是核心基础。其原理在于通过编码软件(如OBS)将音视频数据封装后,经由网络协议推送到服务器,再分发给观众。这项技术的价值在于支撑了实时、高并发的在线互动场景,是直播、在线会议等应用的基石。然而,在追求流量和互动的实践中,衍生出一些非常规操作,例如通过技术手段中断或控制视频流推送,仅保留音频和互动功能,以达到特定运营目的。这便涉及到了**卡黑屏**这一具体现象。它本质上是对直播流的人为干预,常与**流量博弈**和**风险规避**等动机相关联。从工程实践角度看,实现方式多样,

weixin_29895109的博客 1523

PAT(甲级)1031 Hello World for U (20point(s))

题目链接 题目链接 思路 题目大意:这道题真的把我绕进去了;输出u型,竖着着两条边上的元素个数相等,分别是n1,n3,底边元素的个数记为n2;要求 n1 = n3 < n2,并且n1的值尽可能大; 可以这样想,一共有N个字符,分别填到3个边上,所以至少要分成3份,即要用N+2除3,注意有两个元素重复了;N+2除3余数有三种可能: 余数为零,三条边元素个数相等; 余数为1,因为要求n1 < n2,所以要把多的这个元素放到底边,底边比侧边多一个元素; 余数为2,底边比侧边多2个元素; 没有其他可能了

hjyp的博客 155

什么是无人机巡检?如何实现无人机自动巡检?

复亚智能的无人机自动巡检系统通过高度自动化的技术,实现了无人机的高效巡检作业。无人机自动机场支持无人机的自动起降和电池更换,自动飞行算法确保无人机在复杂环境中的精准飞行和拍摄,而云端识别诊断和AI感知算法平台则实现图像的实时传输和智能分析。复亚智能,作为无人机技术的创新者和推动者,致力于开发先进的无人机自动巡检解决方案,助力各行各业实现智能化、自动化的巡检工作,引领智能巡检的未来。利用人工智能和机器学习算法,无人机可以被训练来识别特定的模式和异常,如结构损坏、热泄漏等,从而提高巡检的准确性和效率。

foiadrone的博客 2857

树莓派4B:控制步进电机

文章目录准备阶段接线阶段树莓派程序 准备阶段 准备以下物品,淘宝都可以买到: 57步进电机 电源开关(220v转24v,3A,72W) 步进电机驱动器 电源线 电线 杜邦线 树莓派4B一套 具体型号如下: 接线阶段 整体:接线效果如下图 电源开关起220v转24v作用,很好接线,输出24v接入步进电机驱动器 步进电机驱动器的 A+ A- B+ B- 按提示接步进电机四线,步进电机上就会有说...

学习路上的鸭子的博客 1万+

PAT 1031 Hello World for U (20 分) Python

1031 Hello World for U Python

LoveFishO的博客 387

Win11 C盘爆满别慌!手把手教你安全迁移AppData和用户文件夹(附一键脚本)

本文针对Win11 C盘空间不足问题,提供了一套安全有效的解决方案。通过深入解析用户目录结构,指导用户利用符号链接和Robocopy工具,将AppData、下载文档等占用大户迁移至其他分区,并附带了自动化脚本,从根本上实现C盘瘦身,同时确保系统稳定和数据安全。

weixin_29231221的博客 2168

Given any string of N (>=5) characters, you are asked to form the characters into the shape of U.

题目描述 Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, “helloworld” can be printed as: h d e l l r lowo That is, the characters m...

呢喃 873

【YOLOv11】从零搭建基于YOLOv11深度学习算法的农作物虫害检测系统(附带环境搭建+完整代码+讲解)

《基于YOLOv11的农作物病虫害智能检测系统》项目摘要 本项目开发了一个基于YOLOv11深度学习算法的农作物病虫害检测系统,支持玉米、水稻、草莓和西红柿等四大类经济作物的30多种病虫害识别。系统采用多模态检测方式,支持图片、视频和实时摄像头输入,并集成了完整的Web应用框架。 技术架构上,系统以PyTorch实现YOLOv11算法为核心,结合Flask搭建深度学习服务,SpringBoot构建业务后端,Vue3+TypeScript开发前端界面,MySQL数据库存储检测数据。系统具备用户权限管理功能,支

AnChenliang_1002的博客 828

YOLOv13改进策略【Head】| (独家改进)结合 ICME-2024 中的PPA注意力模块,自研带有注意力机制的小目标检测头

本文记录的是利用PPA (并行补丁感知注意模块)改进YOLOv13的检测头。通过改进传统卷积,形成带有注意力机制的小目标检测头,使模型能够更好地关注小目标的重要信息。HCF-Net: Hierarchical Context Fusion Network for Infrared Small Object Detection采用多分支特征提取策略,通过不同分支提取不同尺度和层次的特征。利用局部、全局和串行卷积分支,对输入特征张量进行处理。通过控制 patch size参数实现局部和全局分支的区分,计算非重叠

Limiiiing的博客 492

1031 Hello World for U (20分) 测试点5错误的坑

1031 Hello World for U (20分) Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l l r lowo That is, the characters must be printed in the original order, star

weixin_45331809的博客 490

【立创EDA-PCB设计基础】4.模块化布局

本文对本专栏绘制的原理图进行模块化布局,首先进行预布局(将每个模块放一起),然后进行精细化布局(按照原理图来精细化布局)。

嵌入式阿齐Archie 3万+

PAT甲级题解(仅供参考,可能有误,持续更新)

本人菜狗一枚,写本篇文章主要用于记录个人的PAT甲级刷题过程,代码和思路可能有误,欢迎指正。

a131529的博客 1509

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

jre9下载 jdk9

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

1031 Hello World for U (20 分)

1031 Hello World for U (20 分) Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l l r lowo That is, the characters must be printed in the original order,

FG_future的博客 277

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

PAT甲级1031 Hello World for U

Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l l r lowo That is, the characters must be printed in the original order, starting top-down from the left

冷眼看world的博客 161

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

浙江大学PAT_甲级_1031. Hello World for U (20)

C++

~~(v_v)~~ 576

PAT甲级 1031

PAT甲级 1031题目 Hello World for U解析代码 题目 Hello World for U Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h ...

qq_37208650的博客 180

【一只蒟蒻的刷题历程】 【PAT】 A1031 Hello World for U

Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l l r lowo That is, the characters must be printed...

黑桃 332

PAT甲级 A1031

PAT甲级 A1031 题目情况 Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l l r lowo That is, the characters must be printed in the original order, starting top-down f

weixin_44065549的博客 228

PAT-python-1031 Hello World for U

Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l l r lowo Input Specification: Each input file contains one test case. Each case contains one strin

陆沙的博客 416

PAT 1032 挖掘机技术哪家强(JAVA)

为了用事实说明挖掘机技术到底哪家强,PAT 组织了一场挖掘机技能大赛。现请你根据比赛结果统计出技术最强的那个学校。 输入格式: 输入在第 1 行给出不超过 105​​ 的正整数 N,即参赛人数。随后 N 行,每行给出一位参赛者的信息和成绩,包括其所代表的学校的编号(从 1 开始连续编号)、及其比赛成绩(百分制),中间以空格分隔。 输出格式: 在一行中给出总得分最高的学校的编号、及其总分,中间以空...

qq_37774375的博客 420

【PAT(甲级)】1031 Hello World for U(详细的解题思路)

【PAT(甲级)】1031 Hello World for U 详细的解题思路分享

weixin_55202895的博客 319

PAT1032 挖掘机技术哪家强 (20 分) Java实现 解决了第三个测试点不通过的问题

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.HashMap; /** * @date 2021-8-25 - 18:19 * Created by Salmon */ public class Main { public static void main.

Salmon1122的博客 353

Hello World for U

Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as: h d e l l r lowo That is, the characters must be pr

sheng_xc的专栏 735

问题 B: Hello World for U

题目描述 Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, “helloworld” can be printed as: h d e l l r lowo That is, the characters must ...

Quebec_forever的博客 267
上一篇: PAT甲级1028,1029解题报告
下一篇: PAT甲级1035,1036解题报告
Tate_Brown
博客等级 码龄9年 39粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址