PAT甲级题解
里面包括本人做过的所有PAT甲级试题。
······
如今是这个专栏创建一年后。我之前写了些什么垃圾啊,怪不得做了这么多题还是菜的不行,基础不牢,地动山摇,貌似都会,其实都是模棱两可,一考试就gg。19年9月还得考pat甲级,在此写题解。
yiichan
这个作者很懒,什么都没留下…
展开
-
1140 Look-and-say Sequence (20 分)
1140 Look-and-say Sequence (20 分) 依次输出串中连续元素的个数这道题其实靠的就是个模拟,依次输出并转化串中连续元素的个数,但是我居然这都不会写了?!这也太菜了吧!网上找到的是对字符串处理的,我自己写了一个对数组进行这种处理的。也就是说可以出一个这样的题目:给出一个整型数组a的容量和元素序列,请输出另一个整型数组b,b为a中的连续元素和每个连续元素的个数。...原创 2019-11-01 07:43:19 · 357 阅读 · 0 评论 -
记2018年9月PAT甲级考试(北京工业大学考场)
这次第一题就给人很意外,是个提交正确率和最后一题正确率一样低的题,不像以前一样水了。我吭哧吭哧做了半个多小时,才发现题读错了,扑街,第一次放弃。接着做第二题,像是道并查集,但是并查集我很久没写了,忘了怎么写了,不会了,就用了个set模拟,但是STL库我又忘了set的查找功能到底返回的是什么了,试了很久发现查找失败不等价于迭代器!=end(),所以自己写了个小程序试了试,最后才搞明白set.fi...原创 2018-09-08 23:08:40 · 1988 阅读 · 2 评论 -
1001 A+B Format(20 分)
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 Speci...原创 2018-09-03 21:33:48 · 358 阅读 · 0 评论 -
1110 Complete Binary Tree (25 分)
1110 Complete Binary Tree (25 分)Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line give...原创 2019-08-13 20:45:10 · 252 阅读 · 0 评论 -
1119 Pre- and Post-order Traversals (30 分)
1119 Pre- and Post-order Traversals (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 tra...原创 2019-08-14 19:16:01 · 295 阅读 · 0 评论 -
1127 ZigZagging on a Tree (30 分)
1127 ZigZagging 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-08-14 20:21:52 · 784 阅读 · 0 评论 -
1141 PAT Ranking of Institutions (25 分) 复杂结构体排序 一堆花里胡哨STL的拼凑
After each PAT, the PAT Center will announce the ranking of institutions based on their students’ performances. Now you are asked to generate the ranklist.Input Specification:Each input file contain...原创 2019-08-05 21:29:46 · 182 阅读 · 0 评论 -
1142 Maximal Clique (25 分) 最大团
A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adj...原创 2019-08-02 21:49:48 · 245 阅读 · 0 评论 -
1143 Lowest Common Ancestor (30 分) 二叉搜索树(BST)两节点的最近共同祖先
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 defined as a binary tree which has ...原创 2019-07-31 21:12:47 · 226 阅读 · 0 评论 -
1145 Hashing - Average Search Time (25 分) 哈希表 平均查找长度
题干太长了,这次不写题干了,主要说说散列表,又叫哈希表(hash table)散列表是一种存储数据的方法,通过散列表,可以实现直接用关键字(key)访问数据所在位置。具体实现方法为使用散列函数(哈希函数)H(key),对每个关键字,都可以计算出一个地址。显然,不同的关键字可能有同一个地址,造成地址冲突,有解决这些地址冲突的方法。H(key)=address哈希函数有很多种构造方法,常用的有...原创 2019-07-29 21:27:04 · 357 阅读 · 0 评论 -
1146 Topological Order (25 分) 拓扑排序 判定
也不写题干了,主要说说拓扑排序。对一个有向图G,我们把满足下列要求的顶点序列叫做G的拓扑排序,一般来说,一个图的拓扑排序不唯一。(1)拓扑排序中的,对每一个节点,它的后继节点都在该节点之后出现。(2)如果两节点没有直接间接的前驱后继关系,则两节点在序列中先后顺序不限(3)每个拓扑排序包含G的所有节点有向无环图(简称DAG):没有回路的有向图叫做有向无环图。比如下图(就是pat 甲级...原创 2019-07-30 18:25:16 · 336 阅读 · 0 评论 -
1147 Heaps (30 分) 堆的判断 静态树
In computer science, a heap is 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 than or equal to (i...原创 2019-07-30 21:59:40 · 306 阅读 · 0 评论 -
1148 Werewolf - Simple Version (20 分) 狼人杀简化版(其实一点也不简化) 条件逻辑
1148 Werewolf - Simple Version (20 分)Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: "Play...原创 2019-07-26 20:34:47 · 682 阅读 · 0 评论 -
1149 Dangerous Goods Packaging (25 分) 图中的相邻点
When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂)...原创 2019-07-27 19:04:39 · 235 阅读 · 0 评论 -
1150 Travelling Salesman Problem (25 分) 图的路径判定(较易)
The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and retu...原创 2019-07-27 20:45:16 · 168 阅读 · 0 评论 -
1151 LCA in a Binary Tree (30 分)
先放个空博客在这里,暂时按我对树的理解,我觉得这个题我做不出来。原创 2019-07-29 19:32:08 · 184 阅读 · 0 评论 -
1152 Google Recruitment atoi函数和stoi函数
In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit p...原创 2019-07-23 20:06:16 · 221 阅读 · 0 评论 -
1153 Decode Registration Card of PAT (25 分) 复杂结构体排序
一不小心把这个博客重新编辑了,把1153的题解替换成了1154的了,结果整篇博客都没了。。。靠回忆重新补一下吧。A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely, T for the top level, A for advance an...原创 2019-07-25 21:00:02 · 303 阅读 · 0 评论 -
1154 Vertex Coloring (25 分) 适当顶点涂色 手绘样例图
A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic;the 2nd - 4th digits are the test site num...原创 2019-07-24 20:16:22 · 169 阅读 · 0 评论 -
1155 Heap Paths (30 分) 顺序树 深搜遍历树的路径 堆检验
In computer science, a heap is 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 than or equal to (i...原创 2019-07-26 18:52:16 · 143 阅读 · 0 评论 -
1134 Vertex Cover (25 分) 图的特殊存储
1134 Vertex Cover (25 分) 图的特殊存储其实是一道痕简单的题,但是我实在是太菜了。先是英语读错题意了,写了俩错误的程序。然后是明白过来之后用set实现了一遍,发现最后两个用例超时了,所以想了个公式,交上去又超时了,才发现这个公式需要o(n2)复杂度,又扑gai。看了答案才发现就是一个简单的记录数组,或者叫得“学术”一点,叫哈希表,记录每条边出现与否,最后o(n)遍历一...原创 2019-08-26 20:12:30 · 428 阅读 · 2 评论 -
1111 Online Map (30 分)
1111 Online Map (30 分)Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other ...原创 2019-08-31 21:31:12 · 368 阅读 · 0 评论 -
PAT-A-Level 1129 推荐系统 (25 分)
1129 Recommendation System (25 分)Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that rates the user...原创 2019-09-03 19:25:36 · 287 阅读 · 0 评论 -
1128 N Queens Puzzle (20 分)
1128 N Queens Puzzle (20 分)水题,直接按照当初N皇后的判定条件(就是代码中有注释的那几行)判定判定就行了。#include <bits/stdc++.h>#define N 1005using namespace std;int a[N];int main() { int n,k; cin>>n; for (i...原创 2019-09-03 19:54:31 · 260 阅读 · 0 评论
分享