自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 06-图2 Saving James Bond - Easy Version (25分)

题目 This time let us consider the situation in the movie “Live and Let Die” in which James Bond, the world’s most famous spy, was captured by a group of drug dealers. He was sent to a small piece of la...

2020-03-29 18:54:03 146

原创 06-图1 列出连通集 (25分)

课堂笔记 如果从无向图的任一顶点出发进行一次深度优先搜索可访问所有顶点,则该图一定是连通图。因为连通图只有一个连通分量,即只需从一个起点遍历一次就可以访问所有节点。 题目 给定一个有N个顶点和E条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到N−1编号。进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点。 输入格式: 输入第1行给出2个整数N(0<...

2020-03-28 11:51:27 287

原创 05-树8 File Transfer (25分)

题目 We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any comput...

2020-03-25 11:06:57 113

原创 04-树6 Complete Binary Search Tree (30分)

题目 A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node’s key. The right s...

2020-03-11 12:12:36 112

原创 1023 Have Fun with Numbers (20分)

题目 Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number ...

2020-02-25 18:05:03 132

原创 1099 Build A Binary Search Tree (30 分)

题目 A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node’s key. The right s...

2019-10-28 22:46:43 97

原创 05-树7 堆中的路径 (25 分)

题目 将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任意给定的下标i,打印从H[i]到根结点的路径。 输入格式: 每组测试第1行包含2个正整数N和M(≤1000),分别是插入元素的个数、以及需要打印的路径条数。下一行给出区间[-10000, 10000]内的N个要被插入一个初始为空的小顶堆的整数。最后一行给出M个下标。 输出格式: 对输入中给出的每个下标i,在一行中输出从H[i]到根结点的...

2019-10-27 21:11:38 125

原创 04-树7 二叉搜索树的操作集 (30 分)

题目 函数接口定义: BinTree Insert( BinTree BST, ElementType X ); BinTree Delete( BinTree BST, ElementType X ); Position Find( BinTree BST, ElementType X ); Position FindMin( BinTree BST ); Position FindMax( B...

2019-10-20 11:48:16 827

原创 04-树5 Root of AVL Tree (25 分)

题目 An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing...

2019-10-20 10:43:48 71

原创 04-树4 是否同一棵二叉搜索树 (25 分)

题目 给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。 输入格式: 输入包含若干组测试数据。每组数据的第1行给出两个正整数N (≤10)和L,分别是每个序列插入元素的个数和需要...

2019-10-19 17:03:48 99

原创 03-树3 Tree Traversals Again (25 分)

题目 Given a tree, you are supposed to list all the leaves in the order of top down, and left to right. Input Specification: Each input file contains one test case. For each case, the first line gives ...

2019-10-19 10:21:13 84

原创 pat甲级 大整数、链表类题目总结

题目分类源自PAT甲级真题目录 大整数 大整数 1023. Have Fun with Numbers (20)-PAT甲级真题(大整数运算) 1024. Palindromic Number (25)-PAT甲级真题(大整数相加) 总结:1.struct是个宝;2.一定要用字符串转数组;3.两数加减时一定要注意数组中的运算顺序。 struct bign{ int d[MAX]; int le...

2019-10-13 17:27:32 175

原创 02-线性结构3 Reversing Linked List (25 分)

题目 ositive K (≤N) which is the length of the sublist to be reversed. The address of a node is a 5-digit nonnegative integer, and NULL is represented by -1. Then N lines follow, each describes a node i...

2019-10-09 20:57:51 95

原创 02-线性结构2 一元多项式的乘法与加法运算 (20 分)

题目 设计函数分别求两个一元多项式的乘积与和。 输入格式: 输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。 输出格式: 输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应输出0 0。 输入样例: 4 3 4 -5 2 6 ...

2019-10-07 21:56:38 88

原创 02-线性结构1 两个有序链表序列的合并 (15 分)

题目 本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列。 函数接口定义: List Merge( List L1, List L2 ); 其中List结构定义如下: typedef struct Node PtrToNode; struct Node { ElementType Data; / 存储结点数据 / PtrToNode Next; / 指向下一个结点的指...

2019-09-28 21:13:44 128

原创 pat甲级1015

题目 1015 Reversible Primes (20 分) A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime be...

2019-09-26 16:42:15 60

原创 菜鸟笔记:03-树1 树的同构 (25 分)

题目 给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。 图1 图2 现给定两棵树,请你判断它们是否是同构的。 输入格式: 输入给出2棵二叉树树的信息。对于每棵树,首先在一行中给出一个非负整数N (≤10),即该树的结点数(此时假...

2019-08-22 10:28:43 110

原创 算法竞赛入门经典例题6-2铁轨

简单的写一下对算法的理解。 #include<cstdio> #include<stack> using namespace std; const int maxn = 1000 + 10; int n,target[maxn]; int main(){ while(scanf("%d",&n)==1){ stack<int>s; int A=...

2019-08-14 11:59:37 193

原创 PAT甲级1001

题目 1001 A+B Format (20 分) Calculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits). Input Spe...

2019-08-12 17:30:25 89

原创 PAT乙级1005 继续(3+1)猜想

题目 卡拉兹(Callatz)猜想已经在1001中给出了描述。在这个题目里,情况稍微有些复杂。 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数。例如对 n=3 进行验证的时候,我们需要计算 3、5、8、4、2、1,则当我们对 n=5、8、4、2 进行验证的时候,就可以直接判定卡拉兹猜想的真伪,而不需要重复计算,因为这 4 个数已经在验证3的时候遇到过了,我们称 5...

2019-07-19 10:21:07 152

原创 PAT (Basic Level) Practice 1002(c)

题目分析 读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字。 输入格式: 每个测试输入包含 1 个测试用例,即给出自然数 n 的值。这里保证 n 小于 10 ​100 ​​ 。 输出格式: 在一行内输出 n 的各位数字之和的每一位,拼音数字间有 1 空格,但一行中最后一个拼音数字后没有空格。 本题大致可以分为几步 输入字符串,将字符串转换为数组 求和,将结果分位存至数组 按位...

2019-07-18 11:38:12 73

原创 害死人不偿命的(3n+1)猜想(c++)

题目分析 卡拉兹(Callatz)猜想: 对任何一个正整数 n,如果它是偶数,那么把它砍掉一半;如果它是奇数,那么把 (3n+1) 砍掉一半。这样一直反复砍下去,最后一定在某一步得到 n=1。卡拉兹在 1950 年的世界数学家大会上公布了这个猜想,传说当时耶鲁大学师生齐动员,拼命想证明这个貌似很傻很天真的命题,结果闹得学生们无心学业,一心只证 (3n+1),以至于有人说这是一个阴谋,卡拉兹是在蓄意...

2019-07-18 10:10:32 498

原创 杭电oj1002(c++)

题目分析 Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. Input The first line of the input contains an integer T(1<=T&lt...

2019-07-16 11:44:43 992

原创 杭电oj1001(c++)

题目分析 Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + … + n. Input The input will consist of a series ...

2019-07-15 17:50:11 451

原创 杭电oj1000(c++)

题目分析 Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For each case, output A + B in one line. 这是一道简单的题目,输入两个数字并输出相加结果。值得一提的是"proc...

2019-07-15 17:26:21 536

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除