
PAT甲级题
焱然飞
这个作者很懒,什么都没留下…
展开
-
1136. A Delayed Palindrome (20)
Consider a positive integer N written in standard notation with k+1 digits ai as ak...a1a0 with 0 i < 10 for all i and ak > 0. Then N is palindromic if and only if ai = ak-i for all i. Zero is writt原创 2018-01-19 15:55:58 · 159 阅读 · 0 评论 -
1094. The 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 with the largest population.Inpu原创 2018-01-25 09:57:10 · 177 阅读 · 0 评论 -
1076. Forwards on Weibo (30)
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a原创 2018-02-01 09:47:17 · 244 阅读 · 0 评论 -
1112. Stucked Keyboard (20)
On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for k times.Now given a resu原创 2018-01-17 10:05:28 · 132 阅读 · 0 评论 -
1071. Speech Patterns (25)
People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzing such patterns can help to narrow down a speaker原创 2018-01-17 09:19:04 · 134 阅读 · 0 评论 -
1100. Mars Numbers (20)
People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars.The numbers 1 to 12 on Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec" on Ma原创 2018-01-17 08:58:09 · 167 阅读 · 0 评论 -
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 because its reverse 37 is also a pr原创 2018-01-16 16:10:57 · 105 阅读 · 0 评论 -
1081. Rational Sum (20)
Given N rational numbers in the form "numerator/denominator", you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positi原创 2018-01-16 10:13:28 · 135 阅读 · 0 评论 -
1115. Counting 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 less than or equal to the node's ke原创 2018-01-31 11:21:41 · 214 阅读 · 0 评论 -
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原创 2018-01-25 15:14:14 · 230 阅读 · 0 评论 -
1064. 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 righ原创 2018-01-25 15:35:01 · 206 阅读 · 0 评论 -
1124. Raffle for Weibo Followers (20)
John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give原创 2018-01-17 08:46:52 · 148 阅读 · 0 评论 -
1105. Spiral Matrix (25)
This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then move in原创 2018-01-19 10:01:59 · 134 阅读 · 0 评论 -
1046. Shortest Distance (20)
The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file contains原创 2018-01-19 09:31:27 · 136 阅读 · 0 评论 -
1065. A+B and C (64bit) (20)
Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C.Input Specification:The first line of the input gives the positive number of test cases, T (Output Specificatio原创 2018-01-19 08:57:51 · 155 阅读 · 0 评论 -
1134. Vertex Cover (25)
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 if e原创 2018-01-18 09:50:43 · 215 阅读 · 0 评论 -
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's preference by the number of time转载 2018-01-18 09:36:07 · 315 阅读 · 0 评论 -
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-01-18 09:02:11 · 136 阅读 · 0 评论 -
1120. Friend Numbers (20)
Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are friend numbers since 1+2+3 = 5+1 = 6, and 6 is their原创 2018-01-18 08:24:03 · 138 阅读 · 0 评论 -
1079. Total Sales of Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on原创 2018-01-24 09:47:06 · 177 阅读 · 0 评论 -
1090. Highest Price in Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on原创 2018-01-24 09:25:41 · 190 阅读 · 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 stac原创 2018-01-31 09:42:45 · 167 阅读 · 0 评论 -
1096. Consecutive Factors (20)
Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3*5*6*7, where 5, 6, and 7 are the three consecutive numbers. Now given原创 2018-01-15 09:39:38 · 133 阅读 · 0 评论 -
1128. N Queens Puzzle (20)
The "eight queens puzzle" is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row原创 2018-01-15 09:12:53 · 122 阅读 · 0 评论 -
1116. Come on! Let's C (20)
"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny原创 2018-01-15 08:47:57 · 199 阅读 · 0 评论 -
1117. Eddington Number(25)
1117. Eddington Number(25)British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- that is, the maximum原创 2018-01-15 08:16:20 · 235 阅读 · 0 评论 -
1097. Deduplication on a Linked List (25)
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a原创 2018-01-22 15:03:15 · 241 阅读 · 0 评论 -
1133. Splitting A Linked List (25)
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea原创 2018-01-22 14:18:25 · 149 阅读 · 0 评论 -
1137. Final Grading (25)
For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from原创 2018-01-22 09:10:21 · 218 阅读 · 0 评论 -
1125. Chain the Ropes (25)
Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the figure. The resulting chai原创 2018-01-22 08:16:27 · 151 阅读 · 0 评论 -
1074. Reversing Linked List (25)
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K = 3, then you must output 3→2→1→6→5→4; if K原创 2018-01-23 08:52:09 · 118 阅读 · 0 评论 -
1052. Linked 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 integer key and a Next pointer to the next structure. Now give原创 2018-01-23 09:16:42 · 143 阅读 · 0 评论 -
1020. Tree 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 traversal sequence of the cor原创 2018-01-31 09:14:00 · 213 阅读 · 0 评论 -
1118. Birds in Forest (25)
Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the scientists to count the maxi转载 2018-01-23 16:22:40 · 145 阅读 · 0 评论 -
1069. The Black Hole of Numbers (20)
For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by takin原创 2018-01-16 09:13:48 · 141 阅读 · 0 评论 -
1104. Sum of Number Segments (20)
Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence {0.1, 0.2, 0.3, 0.4}, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3)原创 2018-01-16 08:35:46 · 145 阅读 · 0 评论 -
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-01-16 08:22:08 · 245 阅读 · 0 评论 -
1107. Social Clusters (30)
When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A "social cluster" is a set of people who have some of th原创 2018-01-23 15:14:52 · 157 阅读 · 0 评论 -
1093. Count PAT's (25)
The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.No原创 2018-01-15 14:48:59 · 111 阅读 · 0 评论 -
1032. Sharing (25)
To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,原创 2018-01-23 09:48:18 · 148 阅读 · 0 评论