
PAT甲级
文章平均质量分 92
ME->CS
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
PAT甲级题解目录
这篇文章记录了我做的pat甲级的题目,包含了一些心得和做题方法,在代码前和注释中均有体现。甲级目前已完成137/155,因为还要更新乙级的目录和做甲级的题目,所以更新会比较慢,会陆续更新的。另外我还在做LeetCode的题目,目前完成1264/1600,这个工作量非常大,同时我也是一名大学生,课余时间有限,目前虽然打算做完这三项并更新,但应该需要非常久的时间了。...原创 2019-09-20 23:50:31 · 714 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25分)
Given a sequence of K integers { N1 , N2 , …, NK }. A continuous subsequence is defined to be { Ni , Ni+1 , …, Nj } where 1≤i≤j≤K. The Maximum Subsequence is the contin...原创 2020-01-30 00:24:23 · 259 阅读 · 0 评论 -
1088 Rational Arithmetic (20分)
For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test cas...原创 2020-01-28 18:11:03 · 165 阅读 · 0 评论 -
1070 Mooncake (25分)
Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region’s culture. Now ...原创 2020-01-28 18:03:31 · 186 阅读 · 0 评论 -
1035 Password (20分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L ...原创 2020-01-28 17:53:03 · 166 阅读 · 0 评论 -
1055 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...原创 2020-01-28 17:30:19 · 183 阅读 · 0 评论 -
1037 Magic Coupon (25分)
The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product b...原创 2020-01-28 10:24:05 · 157 阅读 · 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...原创 2020-01-28 10:04:35 · 231 阅读 · 0 评论 -
1036 Boys vs Girls (25分)
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one tes...原创 2019-12-26 11:37:04 · 140 阅读 · 0 评论 -
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 is the fastest. It is g...原创 2019-12-15 20:31:26 · 171 阅读 · 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...原创 2019-10-20 20:20:24 · 127 阅读 · 0 评论 -
1072 Gas Station (30 分)
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou...原创 2019-10-28 19:35:59 · 157 阅读 · 0 评论 -
1062 Talent and Virtue (25 分)
About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people’s talent and virtue. According to his theory, a man being outstanding in both talent and virt...原创 2019-11-05 17:50:54 · 126 阅读 · 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-11-05 12:34:23 · 139 阅读 · 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 contain...原创 2019-11-03 19:16:50 · 150 阅读 · 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 positive integ...原创 2019-11-03 19:01:37 · 140 阅读 · 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-10-29 15:34:08 · 152 阅读 · 0 评论 -
1068 Find More Coins (30 分)
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-10-21 22:41:20 · 188 阅读 · 0 评论 -
1059 Prime Factors (25 分)
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:...原创 2019-10-20 21:55:19 · 163 阅读 · 0 评论 -
1016 Phone Bills (25 分)
A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When ...原创 2019-10-20 20:08:47 · 186 阅读 · 0 评论 -
1085 Perfect Sequence (25 分)
Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum numbers in the sequence, respecti...原创 2019-10-19 18:05:39 · 127 阅读 · 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 subt...原创 2019-10-19 17:58:54 · 196 阅读 · 0 评论 -
1132 Cut Integer (20 分)
Cutting an integer means to cut a K digits lone 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...原创 2019-10-19 17:47:22 · 118 阅读 · 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-19 17:32:03 · 137 阅读 · 0 评论 -
1002 A+B for Polynomials (25 分)
This time, you are supposed to find A+B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the informati...原创 2019-10-19 17:20:00 · 426 阅读 · 0 评论 -
1008 Elevator (20 分)
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 sec...原创 2019-10-19 17:17:32 · 135 阅读 · 0 评论 -
1006 Sign In and Sign Out (25 分)
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in’s and out’s, you...原创 2019-10-19 17:15:14 · 140 阅读 · 0 评论 -
1123 Is It a Complete AVL Tree (30 分)
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 is...原创 2019-10-19 17:03:19 · 195 阅读 · 0 评论 -
1066 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 is...原创 2019-10-19 16:55:55 · 103 阅读 · 0 评论 -
1114 Family Property (25 分)
1114 Family Property (25 分)This time, you are supposed to help us collect the data for family-owned property. Given each person’s family members, and the estate(房产)info under his/her own name, we nee...原创 2019-10-19 16:40:33 · 148 阅读 · 0 评论 -
1095 Cars on Campus (30 分)
Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you a...原创 2019-10-19 14:36:57 · 255 阅读 · 0 评论 -
1135 Is It A Red-Black Tree (30 分)
There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or black.(2) The root is black.(3) Every le...原创 2019-10-18 18:39:12 · 248 阅读 · 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 −...原创 2019-10-18 13:36:42 · 129 阅读 · 0 评论 -
1043 Is It a Binary Search Tree (25 分)
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 subt...原创 2019-10-18 13:28:42 · 744 阅读 · 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-10-18 12:44:30 · 142 阅读 · 0 评论 -
1109 Group Photo (25 分)
Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following:The number of people in each row must be N/K (round down to the nearest integer...原创 2019-10-18 12:21:36 · 145 阅读 · 0 评论 -
1134 Vertex Cover (25 分)
图的顶点覆盖是一组顶点,使得图的每个边均入射到该组的至少一个顶点上。现在给定一个具有多个顶点集的图形,您应该确定它们中的每一个是否都是顶点覆盖。输入规格:每个输入文件包含一个测试用例。对于每种情况,第一行给出两个正整数N和M(均不超过1 04),作为顶点的总数和边缘上,分别 然后随后是M行,每行通过给出索引来描述边缘(从0到ñ - 1)的边缘的两个端部的。图之后是一个正整数 K(≤ 10...原创 2019-10-18 11:57:21 · 149 阅读 · 0 评论 -
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 sequences. And it is a simple stand...原创 2019-10-18 11:48:59 · 249 阅读 · 0 评论 -
1056 Mice and Rice (25 分)
Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice...原创 2019-10-18 11:43:30 · 149 阅读 · 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...原创 2019-10-14 17:29:20 · 138 阅读 · 0 评论