历年上海交通大学计算机保研上机真题

article/2025/7/22 11:56:30

2025上海交通大学计算机保研上机真题
2024上海交通大学计算机保研上机真题
2023上海交通大学计算机保研上机真题
在线测评链接:https://pgcode.cn/school
在这里插入图片描述

String Match

题目描述

Finding all occurrences of a pattern in a text is a problem that arises frequently in text-editing programs. Typically, the text is a document being edited, and the pattern searched for is a particular word supplied by the user. We assume that the text is an array T[1…n] of length n and that the pattern is an array P[1…m] of length m <= n. We further assume that the elements of P and T are all alphabets (∑ = {a, b, …, z}). The character arrays P and T are often called strings of characters.

We say that pattern P occurs with shift s in the text T if 0 <= s <= n and T[s+1…s+m] = P[1…m] (that is, if T[s+j] = P[j], for 1 <= j <= m). If P occurs with shift s in T, then we call s a valid shift; otherwise, we call s an invalid shift. Your task is to calculate the number of valid shifts for the given text T and pattern P.

输入格式

For each case, there are two strings T and P on a line, separated by a single space. You may assume both the length of T and P will not exceed 10^6.

输出格式

You should output a number on a separate line, which indicates the number of valid shifts for the given text T and pattern P.

输入样例
abababab abab
输出样例
3

二次方程计算器

题目描述

设计一个二次方程计算器,用于求解给定的二次方程。

输入格式

每个输入是关于 x 的一个二次方程表达式,为了简单,每个系数都是整数形式。

输出格式

每个案例输出两个实数(由小到大输出,中间由空格隔开),保留两位小数;如果无解,则输出"No Solution"。

输入样例
x^2+x=3x+4
输出样例
-1.24 3.24

WERTYU

题目描述

A common typing error is to place the hands on the keyboard one row to the right of the correct position. So “Q” is typed as “W” and “J” is typed as “K” and so on. You are to decode a message typed in this manner.

输入格式

Input consists of several lines of text. Each line may contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab, BackSp, Control, etc.] are not represented in the input.

输出格式

You are to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.

输入样例
O S, GOMR YPFSU/
输出样例
I AM FINE TODAY.

Simple Sorting

题目描述

You are given an unsorted array of integer numbers. Your task is to sort this array and remove possible duplicated elements occurring in it.

输入格式

For each case, the first line of the input contains an integer number N representing the quantity of numbers in this array (1 ≤ N ≤ 1000). Next N lines contain N integer numbers (one number per each line) of the original array.

输出格式

For each case, output file should contain at most N numbers sorted in ascending order. Every number in the output file should occur only once.

输入样例
6
8
8
7
3
7
7
输出样例
3 7 8

Old Bill

题目描述

Among grandfather’s papers a bill was found:
“72 turkeys $679
The first and last digits of the number representing the total price are faded (denoted by _). What are the two faded digits and what was the price per turkey?

We want to write a program that solves a general version of this problem:
“N turkeys $XYZ

  • N (number of turkeys) is between 1 and 99 (inclusive)
  • The total price originally had 5 digits, but only the middle 3 digits (X, Y, Z) are visible
  • The first digit is nonzero
  • Each turkey costs the same integer price
    Given N, X, Y, Z, find the two faded digits and the original total price. If multiple solutions exist, choose the most expensive one (maximum price per turkey).
输入格式

The first line contains integer N (0 < N < 100). The second line contains three digits X, Y, Z separated by spaces (representing the middle three digits of the total price).

输出格式

Output the two faded digits (first and last) followed by the maximum price per turkey (integer).

输入样例
72
6 7 9
输出样例
3 5 11

Fibonacci

题目描述

The Fibonacci Numbers {0,1,1,2,3,5,8,13,21,34,…} are defined by the recurrence:
F₀ = 0, F₁ = 1, Fₙ = Fₙ₋₁ + Fₙ₋₂ (n ≥ 2).
Write a program to calculate the Fibonacci Numbers.

输入格式

Each case contains a number n, and you are expected to calculate Fₙ (0 ≤ n ≤ 30).

输出格式

For each case, print a number Fₙ on a separate line, which means the nth Fibonacci Number.

输入样例
1
输出样例
1

数字反转

题目描述

12 翻一下是 21,34 翻一下是 43,12+34 是 46,46 翻一下是 64。

现在有两个任意正整数,问这两个数反转的和是否等于两个数的和的反转。

输入格式

每行两个正整数 a 和 b(0 < a, b <= 10000)。

输出格式

如果满足题目的要求输出 a+b 的值,否则输出 NO。

输入样例
12 34
99 1
输出样例
46
NO

涂颜色

题目描述

在这个游戏中,有一个 n 行 m 列的方阵。

现在要为这个方阵涂上黑白两种颜色。

规定左右相邻两格的颜色不能相同。

请你统计有多少种涂色的方法。

由于答案很大,你需要将答案对 1000000007 取模。

1≤n,m≤10^100000

输入格式

输入两个数 n,m

输出格式

输出总共的方案数

输入样例
2 2
输出样例
4

最长平衡子串

题目描述

我们定义满足最多由两种字符组成,并且字符串中两个字符的数量之差的绝对值小于等于 k 的字符串为 k 阶平衡字符串。

例如 abb 就是 1 阶平衡字符串,也是 2 阶平衡字符串。

现在给出一个长度为 n 并且最多由两种字母字符组成的字符串 s。

对于每次询问 qi,求 s 字符串的所有子串中最长的 qi 阶平衡字符串的长度。

输入格式

多组测试数据,对于每组测试数据包含 m+2 行:

  • 第 1 行包含两个整数 n,m(最大 10^5)
  • 第 2 行是一个长度为 n 的字符串 s
  • 接下来 m 行,每行一个整数 qi 表示询问
输出格式

对于每组测试数据的每次询问,输出一个整数表示原字符串的子串中最长的 qi 阶平衡字符串的长度。

输入样例
5 2
baaaa
2
1
输出样例
4
3

最小面积子矩阵

题目描述

一个 N*M 的矩阵,找出这个矩阵中所有元素的和不小于 K 的面积最小的子矩阵(矩阵中元素个数为矩阵面积)。

输入格式

每个案例第一行三个正整数 N,M<=100,表示矩阵大小,和一个整数 K。

接下来 N 行,每行 M 个数,表示矩阵每个元素的值。

输出格式

输出最小面积的值。

如果任意矩阵的和都小于 K,直接输出-1。

输入样例
4 4 10
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
输出样例
1

http://www.hkcw.cn/article/GUJgETlCaI.shtml

相关文章

DeepSeek-R1-0528-Qwen3-8B 本地ollama离线运行使用和llamafactory lora微调

参考: https://huggingface.co/deepseek-ai/DeepSeek-R1-0528-Qwen3-8B 量化版本: https://huggingface.co/unsloth/DeepSeek-R1-0528-Qwen3-8B-GGUF https://docs.unsloth.ai/basics/deepseek-r1-0528-how-to-run-locally 1、ollama运行 升级ollama版本到0.9.0 支持直接…

数字人革新教育:开启智慧教学新时代

随着人工智能技术的迅猛发展&#xff0c;数字人正在逐步走进教育领域&#xff0c;成为传统教学模式的颠覆者。广州深声科技有限公司&#xff08;以下简称“深声科技”&#xff09;凭借其在智能语音、数字人及多模态交互等核心技术上的深厚积累&#xff0c;推出了一系列创新性产…

Linux操作系统之进程(四):命令行参数与环境变量

目录 前言&#xff1a; 什么是命令行参数 什么是环境变量 认识环境变量 PATH环境变量 HOME USER OLDPWD 本地变量 本地变量与环境变量的差异 核心要点回顾 结语&#xff1a; 前言&#xff1a; 大家好&#xff0c;今天给大家带来的是一个非常简单&#xff0c;但也十…

IDA dumpdex经典脚本(记录)

一个dumpdex的IDA插件 毕业了,暂时用不着了,存起来 import idaapi import structdef dumpdex(start, len, target):rawdex idaapi.dbg_read_memory(start, len)fd open(target, wb)fd.write(rawdex)fd.close()def getdexlen(start):pos start 0x20mem idaapi.dbg_read_mem…

第2期:APM32微控制器键盘PCB设计实战教程

第2期&#xff1a;APM32微控制器键盘PCB设计实战教程 一、APM32小系统介绍 使用apm32键盘小系统开源工程操作 APM32是一款与STM32兼容的微控制器&#xff0c;可以直接替代STM32进行使用。本教程基于之前开源的APM32小系统&#xff0c;链接将放在录播评论区中供大家参考。 1…

Redis的安装与使用

网址&#xff1a;Spring Data Redis 安装包&#xff1a;Releases tporadowski/redis GitHub 解压后 在安装目录中打开cmd 打开服务&#xff08;注意&#xff1a;每次客户端连接都有先打开服务&#xff01;&#xff01;&#xff01;&#xff09; 按ctrlC退出服务 客户端连接…

Redis 难懂命令-- ZINTERSTORE

**背景&#xff1a;**学习的过程中 常用的redis命令都能快速通过官方文档理解 但是还是有一些比较难懂的命令 **目的&#xff1a;**写博客记录一下&#xff08;当然也可以使用AI搜索&#xff09; 在Redis中&#xff0c;ZINTERSTORE 是一个用于计算多个有序集合&#xff08;So…

7.atlas安装

1.服务器规划 软件版本参考&#xff1a; https://cloud.google.com/dataproc/docs/concepts/versioning/dataproc-release-2.2?hlzh-cn 由于hive3.1.3不完全支持jdk8,所以将hive的版本调整成4.0.1。这个版本没有验证过&#xff0c;需要读者自己抉择。 所有的软件都安装再/op…

RabbitMQ和MQTT区别与应用

RabbitMQ与MQTT深度解析&#xff1a;协议、代理、差异与应用场景 I. 引言 消息队列与物联网通信的重要性 在现代分布式系统和物联网&#xff08;IoT&#xff09;生态中&#xff0c;高效、可靠的通信机制是构建稳健、可扩展应用的核心。消息队列&#xff08;Message Queues&am…

【技能篇】RabbitMQ消息中间件面试专题

1. RabbitMQ 中的 broker 是指什么&#xff1f;cluster 又是指什么&#xff1f; 2. 什么是元数据&#xff1f;元数据分为哪些类型&#xff1f;包括哪些内容&#xff1f;与 cluster 相关的元数据有哪些&#xff1f;元数据是如何保存的&#xff1f;元数据在 cluster 中是如何分布…

[3D GISMesh]三角网格模型中的孔洞修补算法

&#x1f4d0; 三维网格模型空洞修复技术详解 三维网格模型在扫描、重建或传输过程中常因遮挡、噪声或数据丢失产生空洞&#xff08;即边界非闭合区域&#xff09;&#xff0c;影响模型的完整性与可用性。空洞修复&#xff08;Hole Filling&#xff09;是计算机图形学和几何处…

基于Spring Boot+Vue 网上书城管理系统设计与实现(源码+文档+部署讲解)

技术范围&#xff1a;SpringBoot、Vue、SSM、HLMT、Jsp、PHP、Nodejs、Python、爬虫、数据可视化、小程序、安卓app、大数据、物联网、机器学习等设计与开发。 主要内容&#xff1a;免费功能设计、开题报告、任务书、中期检查PPT、系统功能实现、代码编写、论文编写和辅导、论文…

[ctfshow web入门] web81

信息收集 新增过滤:&#xff0c;伪协议都有:&#xff0c;这意味着伪协议不能用了 if(isset($_GET[file])){$file $_GET[file];$file str_replace("php", "???", $file);$file str_replace("data", "???", $file);$file st…

2025年应用心理学与社会环境国际会议(ICAPSE 2025)

2025年应用心理学与社会环境国际会议&#xff08;ICAPSE 2025&#xff09; 2025 International Conference on Applied Psychology and Social Environment 一、大会信息 会议简称&#xff1a;ICAPSE 2025 大会地点&#xff1a;中国北京 审稿通知&#xff1a;投稿后2-3日内通…

Windows 11 家庭版 安装Docker教程

Windows 家庭版需要通过脚本手动安装 Hyper-V 一、前置检查 1、查看系统 快捷键【winR】&#xff0c;输入“control” 【控制面板】—>【系统和安全】—>【系统】 2、确认虚拟化 【任务管理器】—【性能】 二、安装Hyper-V 1、创建并运行安装脚本 在桌面新建一个 .…

Redis 数据恢复的月光宝盒,闪回到任意指定时间

在数据库的运维工作中&#xff0c;DBA 应该选择哪一种方案&#xff0c;确保 Redis 数据库崩溃后可以对数据进行回档&#xff0c;恢复业务运行&#xff1f; 一般情况下&#xff0c;DBA 可以通过 Redis 原生的持久化机制&#xff0c;如 RDB 快照持久化或者 AOF 日志持久化的方案…

鸿蒙 HarmonyOS - SideBarContainer 组件自学指南

在日常开发中&#xff0c;如果你有类似「左侧导航 右侧内容」的布局需求&#xff0c;比如后台管理界面、文件管理器、设置页等&#xff0c;​​SideBarContainer​​ 是非常值得掌握的组件。它自带侧边栏和主内容区的分离机制&#xff0c;还支持折叠、拖拽、控制按钮和多种显示…

一个Mybatisplus组件扫描不当引起的bug:弄巧成拙,认真的锅,自我怀疑

在我们系统基建层的业务组件包 sby-biz-component 中&#xff0c;最初&#xff0c;我写了两个业务组件&#xff0c;一个是 通道错误码组件&#xff0c;一个是 审核流水组件。 这两个业务组件都要依赖Mybatisplus来操作数据。 com.sby.bizcomponent├── auditflow│ └── A…

t015-预报名管理系统设计与实现 【含源码!!!】

项目演示地址 摘 要 传统办法管理信息首先需要花费的时间比较多&#xff0c;其次数据出错率比较高&#xff0c;而且对错误的数据进行更改也比较困难&#xff0c;最后&#xff0c;检索数据费事费力。因此&#xff0c;在计算机上安装预报名管理系统软件来发挥其高效地信息处理的…

数学建模之最短路径问题

1 问题的提出 这个是我们的所要写的题目&#xff0c;我们要用LINGO编程进行编写这个题目&#xff0c;那么就是需要进行思考这个怎么进行构建这个问题的模型 首先起点&#xff0c;中间点&#xff0c;终点我们要对这个进行设计 2 三个点的设计 起点的设计 起点就是我们进去&am…