
PAT甲级刷题记录
永夜莫明
菜是原罪
展开
-
PAT甲级刷题记录汇总(持续更新)
模拟1005 Spell It Right (20 分)(简单模拟)1008 Elevator (20 分)(模拟,题目不太好读)1009 Product of Polynomials (25 分)(多项式模拟)1011 World Cup Betting (20 分)(题目难读,每行找个最大值???)1012 The Best Rank (25 分)(排序,排名类模拟)1...原创 2019-11-25 19:31:49 · 517 阅读 · 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-12-04 23:01:48 · 220 阅读 · 0 评论 -
1110 Complete Binary Tree (25 分)(完全二叉树,注意读题,哭了)
1110Complete 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 g...原创 2019-12-04 14:21:37 · 426 阅读 · 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-12-02 09:25:34 · 360 阅读 · 0 评论 -
1010 Radix (25 分)(溢出,二分)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive inte...原创 2019-12-02 08:57:32 · 237 阅读 · 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-11-28 21:20:22 · 180 阅读 · 0 评论 -
1122 Hamiltonian 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 supposed to tell if a given cycle ...原创 2019-11-28 16:36:48 · 236 阅读 · 0 评论 -
1068 Find More Coins (30 分)(01背包 字典序最小方案输出)
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. Howev...原创 2019-11-28 03:52:53 · 159 阅读 · 0 评论 -
1045 Favorite Color Stripe (30 分)(dp,最长上升子序列变形)
Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts...原创 2019-11-28 02:56:40 · 132 阅读 · 0 评论 -
1057 Stack (30 分)(栈模拟+线段树)
Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the top position) and...原创 2019-11-28 02:10:18 · 220 阅读 · 0 评论 -
1040 Longest Symmetric String (25 分)(最长回文子串manacher)
Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&TAP symmetric?, the longest symmetric sub-string is s PAT&TAP s, hence you ...原创 2019-11-27 21:54:03 · 135 阅读 · 0 评论 -
1126 Eulerian Path (25 分)(欧拉通路、欧拉回路、欧拉图)
In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They were firs...原创 2019-11-27 21:17:08 · 156 阅读 · 0 评论 -
1059 Prime Factors (25 分)(唯一分解定理,特判1=1,呵呵)
Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1k1×p2k2×⋯×pmkm.Input Specification:Each input file...原创 2019-11-27 01:20:21 · 139 阅读 · 0 评论 -
1051 Pop Sequence (25 分)(栈模拟,注意初始化)
Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of t...原创 2019-11-27 00:53:23 · 160 阅读 · 0 评论 -
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 de ll rlowoThat is, the characters must be prin...原创 2019-11-27 00:40:02 · 197 阅读 · 0 评论 -
1136 A Delayed Palindrome (20 分)(回文数,大数加法)
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 with 0≤ai<10 for all i and ak>0. Then N is palindromic if and only if ai=ak−i for...原创 2019-11-27 00:26:59 · 136 阅读 · 0 评论 -
1145 Hashing - Average Search Time (25 分)(hash 平方探测法)
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 keys from the table and output the average sea...原创 2019-11-26 14:39:38 · 177 阅读 · 0 评论 -
1134 Vertex Cover (25 分)(vector+暴力模拟)
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell i...原创 2019-11-25 22:30:41 · 171 阅读 · 0 评论 -
1092 To Buy or Not to Buy (20 分)(简单模拟)
Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sel...原创 2019-11-25 19:43:29 · 129 阅读 · 0 评论 -
1084 Broken Keyboard (20 分)(简单模拟,字符串)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to...原创 2019-11-25 18:50:22 · 156 阅读 · 0 评论 -
1050 String Subtraction (20 分)(从字符串中去掉特定的字符)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1−S2 for any give...原创 2019-11-25 18:09:56 · 146 阅读 · 0 评论 -
1048 Find Coins (25 分)(简单模拟,注意访问是否越界)
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However,...原创 2019-11-25 17:56:19 · 153 阅读 · 0 评论 -
1041 Be Unique (20 分)(简单模拟,出现次数统计)
Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,104]. The first one who bets o...原创 2019-11-25 16:52:05 · 191 阅读 · 0 评论 -
1078 Hashing (25 分)(hash 平方探测法)
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 to be H(key)=key%TSiz...原创 2019-11-25 16:23:56 · 192 阅读 · 0 评论 -
1025 PAT Ranking (25 分)(排序,排名类模拟)
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists w...原创 2019-10-30 11:01:18 · 205 阅读 · 1 评论 -
1024 Palindromic Number (25 分)(大数加简单模拟)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...原创 2019-10-30 10:27:30 · 170 阅读 · 0 评论 -
1023 Have Fun with Numbers (20 分)(简单模拟大数加)
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 happe...原创 2019-10-30 08:50:41 · 238 阅读 · 0 评论 -
1019 General Palindromic Number (20 分)(回文数,模拟水题)
A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...原创 2019-10-03 18:11:58 · 131 阅读 · 0 评论 -
1015 Reversible Primes (20 分)(素数)
Areversible primein 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 because its reverse 37 is also a pr...原创 2019-10-03 17:51:35 · 132 阅读 · 0 评论 -
1012 The Best Rank (25 分)(排序,排名类模拟)
To evaluate the performance of our first year CS majored students, we consider their grades of three courses only:C- C Programming Language,M- Mathematics (Calculus or Linear Algrbra), andE- Eng...原创 2019-10-03 15:55:38 · 265 阅读 · 0 评论 -
1013 Battle Over Cities (25 分)(图的遍历,dfs求强连通分量数)
It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we nee...原创 2019-10-03 15:21:21 · 147 阅读 · 0 评论 -
1011 World Cup Betting (20 分)(题目难读,每行找个最大值???)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Si...原创 2019-10-03 14:54:45 · 165 阅读 · 0 评论 -
1009 Product of Polynomials (25 分)(多项式模拟)
https://pintia.cn/problem-sets/994805342720868352/problems/994805509540921344This time, you are supposed to findA×BwhereAandBare two polynomials.Input Specification:Each input file contain...原创 2019-10-02 20:35:41 · 151 阅读 · 0 评论 -
1008 Elevator (20 分)(模拟,题目不太好读)
The highest building in our city has only one elevator. A request list is made up withNpositive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 sec...原创 2019-10-02 19:38:01 · 252 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25 分)(有坑,最大子段和)
https://pintia.cn/problem-sets/994805342720868352/problems/994805514284679168Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...原创 2019-10-02 19:16:19 · 481 阅读 · 0 评论 -
1006 Sign In and Sign Out (25 分)(排序水题)
https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who...原创 2019-10-02 18:30:41 · 136 阅读 · 0 评论 -
1005 Spell It Right (20 分)(简单模拟)
Given a non-negative integerN, your task is to compute the sum of all the digits ofN, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Eac...原创 2019-10-02 17:19:22 · 224 阅读 · 0 评论 -
1004 Counting Leaves (30 分)(广搜,树的遍历)
https://pintia.cn/problem-sets/994805342720868352/problems/994805521431773184A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child....原创 2019-10-02 17:06:48 · 161 阅读 · 0 评论