![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT
文章平均质量分 64
zjykshen
这个作者很懒,什么都没留下…
展开
-
PAT1055:The World's Richest (25)
Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the peopl原创 2018-03-17 22:50:44 · 144 阅读 · 0 评论 -
1102 Invert a Binary Tree (25 分) 已知二叉树,镜像输出层序中序
1102Invert a Binary Tree(25 分)The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so...原创 2019-02-27 20:35:45 · 89 阅读 · 0 评论 -
1094 The Largest Generation (25 分)找最多孩子的那一层的深度和宽度
1094The Largest Generation(25 分)A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation ...原创 2019-02-28 10:51:12 · 141 阅读 · 0 评论 -
1003 Emergency (25 分)(给出一棵树,问每一层各有多少叶子结点 )
1003Emergency(25 分)As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams...原创 2019-02-28 11:20:04 · 153 阅读 · 0 评论 -
1155 Heap Paths (30 分) 有关堆的题
1155Heap Paths(30 分)In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either gre...原创 2019-02-28 14:14:53 · 226 阅读 · 0 评论 -
1143 Lowest Common Ancestor (30 分)通过中序和前序建树,求LCA
1143Lowest Common Ancestor(30 分)The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively...原创 2019-03-01 11:19:49 · 209 阅读 · 0 评论 -
1147 Heaps (30 分)完全二叉树的建树,判断堆
1147Heaps(30 分)In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater ...原创 2019-03-01 13:55:30 · 299 阅读 · 0 评论 -
1145 Hashing - Average Search Time (25 分)哈希平方探查法
1145Hashing - Average Search Time(25 分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer key...原创 2019-03-01 15:51:53 · 141 阅读 · 0 评论 -
1078 Hashing (25 分)hash 二次探测
1078Hashing(25 分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined ...原创 2019-03-01 16:54:53 · 843 阅读 · 0 评论 -
1127 ZigZagging on a Tree (30 分)稍微复杂一点的层序遍历
1127ZigZagging on a Tree(30 分)Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal s...原创 2019-03-01 19:13:13 · 327 阅读 · 0 评论 -
1052 Linked List Sorting (25 分)链表排序
1052Linked List Sorting(25 分)A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integerkeyand aNextpointe...原创 2019-03-01 20:19:54 · 105 阅读 · 0 评论 -
1122 Hamiltonian Cycle (25 分)判断是否为哈密尔顿路
1122Hamiltonian Cycle(25 分)The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a "Hamiltonian cycle".In this problem, you are sup...原创 2019-03-02 09:17:00 · 492 阅读 · 0 评论 -
1115 Counting Nodes in a BST (30 分)排序二叉树的建立(还没学会)
1115Counting Nodes in a BST(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 le...原创 2019-03-02 11:08:06 · 134 阅读 · 0 评论 -
1020 Tree Traversals (25 分)(已知后序和中序求层序)
1020Tree Traversals(25 分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order ...原创 2019-02-27 19:37:26 · 147 阅读 · 0 评论 -
1086 Tree Traversals Again (25 分) 根据先序中序写出后序
An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the s...原创 2019-02-27 19:25:11 · 144 阅读 · 0 评论 -
PAT 1097 Deduplication on a Linked List
题目大意:给出一个链表,对重复的元素(绝对值相同的),只保留第一个出现的,并将所以其余的重复按顺序形成一个新链表。理解:用两个来存,一个存要的链表,一个存删除的结点#include<bits/stdc++.h>using namespace std;const int maxn = 100000;struct node{ int data; int start;...原创 2019-01-02 16:06:08 · 104 阅读 · 0 评论 -
PAT 1132. Cut Integer (20)
Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting原创 2018-03-17 23:51:08 · 116 阅读 · 0 评论 -
PAT :1121. Damn Single (25) 第二个测试点过不去 希望能有知道的大佬指点
"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of.Input Specification:Each input fi...原创 2018-03-18 11:08:48 · 555 阅读 · 2 评论 -
L2-019. 悄悄关注 map的运用
新浪微博上有个“悄悄关注”,一个用户悄悄关注的人,不出现在这个用户的关注列表上,但系统会推送其悄悄关注的人发表的微博给该用户。现在我们来做一回网络侦探,根据某人的关注列表和其对其他用户的点赞情况,扒出有可能被其悄悄关注的人。输入格式:输入首先在第一行给出某用户的关注列表,格式如下:人数N 用户1 用户2 …… 用户N其中N是不超过5000的正整数,每个“用户i”(i原创 2018-03-23 13:22:44 · 169 阅读 · 0 评论 -
L1-040. 最佳情侣身高差(有坑点)
专家通过多组情侣研究数据发现,最佳的情侣身高差遵循着一个公式:(女方的身高)×1.09=(男方的身高)。如果符合,你俩的身高差不管是牵手、拥抱、接吻,都是最和谐的差度。下面就请你写个程序,为任意一位用户计算他/她的情侣的最佳身高。输入格式:输入第一行给出正整数N(输出格式:对每一个查询,在一行中为该用户计算出其情侣的最佳身高,保留小数点后2位。输入样例:原创 2018-03-19 21:52:39 · 3494 阅读 · 0 评论 -
L1-039 古风排版 同样的输出连样例都过不了??
中国的古人写文字,是从右向左竖向排版的。本题就请你编写程序,把一段文字按古风排版。输入格式:输入在第一行给出一个正整数N(<100),是每一列的字符数。第二行给出一个长度不超过1000的非空字符串,以回车结束。输出格式:按古风格式排版给定的字符串,每列N个字符(除了最后一列可能不足N个)输入样例:4This is a test case输出样例:asa Tst ihe tsi ce...原创 2018-03-19 23:00:38 · 262 阅读 · 0 评论 -
L2-021. 点赞狂魔
微博上有个“点赞”功能,你可以为你喜欢的博文点个赞表示支持。每篇博文都有一些刻画其特性的标签,而你点赞的博文的类型,也间接刻画了你的特性。然而有这么一种人,他们会通过给自己看到的一切内容点赞来狂刷存在感,这种人就被称为“点赞狂魔”。他们点赞的标签非常分散,无法体现出明显的特性。本题就要求你写个程序,通过统计每个人点赞的不同标签的数量,找出前3名点赞狂魔。输入格式:输入在第一行给出一个正整数N(&l...原创 2018-03-20 22:04:30 · 144 阅读 · 0 评论 -
1057. 数零壹(20)
给定一串长度不超过105的字符串,本题要求你将其中所有英文字母的序号(字母a-z对应序号1-26,不分大小写)相加,得到整数N,然后再分析一下N的二进制表示中有多少0、多少1。例如给定字符串“PAT (Basic)”,其字母序号之和为:16+1+20+2+1+19+9+3=71,而71的二进制是1000111,即有3个0、4个1。输入格式:输入在一行中给出长度不超过105、以回车结原创 2018-03-26 11:09:34 · 113 阅读 · 0 评论 -
1062. 最简分数(20)
一个分数一般写成两个整数相除的形式:N/M,其中M不为0。最简分数是指分子和分母没有公约数的分数表示形式。现给定两个不相等的正分数 N1/M1 和 N2/M2,要求你按从小到大的顺序列出它们之间分母为K的最简分数。输入格式:输入在一行中按N/M的格式给出两个正分数,随后是一个正整数分母K,其间以空格分隔。题目保证给出的所有整数都不超过1000。输出格式:在一原创 2018-03-26 12:56:15 · 112 阅读 · 0 评论 -
L1-050. 倒数第N个字符串 天梯赛
L1-050. 倒数第N个字符串时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者陈越给定一个完全由小写英文字母组成的字符串等差递增序列,该序列中的每个字符串的长度固定为 L,从 L 个 a 开始,以 1原创 2018-04-01 13:03:21 · 783 阅读 · 0 评论 -
L2-010. 排座位 一个点超时提交了二十次
布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位。无论如何,总不能把两个死对头排到同一张宴会桌旁!这个艰巨任务现在就交给你,对任何一对客人,请编写程序告诉主人他们是否能被安排同席。输入格式:输入第一行给出3个正整数:N(这里假设朋友的朋友也是朋友。但敌人的敌人并不一定就是朋友,朋友的敌人也不一定是敌人。只有单纯直接的敌对关系才是绝对不能同席的。输出格式:原创 2018-03-29 16:13:50 · 111 阅读 · 0 评论 -
大数的溢出,正溢出和负溢出
正溢出:两个整数相加的结果超过了数据类型所能表示的最大范围,结果为负数负溢出:两个负数相加的结果超过了数据类型所能表示的最小范围,结果为正数(包括0)PAT 1065 https://pintia.cn/problem-sets/994805342720868352/problems/994805406352654336看到这道题的第一反应是大数字符串,但是想了想好像会很麻烦后来才...原创 2018-12-26 10:25:03 · 20619 阅读 · 1 评论 -
PAT链表题简单总结
步骤1:定义静态链表。其中结点性质由int型变量order定义,表示结点在链表中的序号(从0开始),其中无效结点为maxn步骤2:初始化。令order的初值均为maxn,表示初始时所有结点都为无效结点步骤3:由题目给出的链表首地址begin遍历整条链表,并记录每个有效结点在链表中的序号,即给order赋值,同时计数有效结点的个数cnt。之后为了方便书写,把cnt赋给n步骤4:对结...原创 2019-01-06 19:42:57 · 393 阅读 · 0 评论 -
1130 Infix Expression (25 分)
Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Each input file contai...原创 2019-02-27 13:06:16 · 129 阅读 · 0 评论