PAT
专属晴天娃娃
这个作者很懒,什么都没留下…
展开
-
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 continuous subsequence which has the largest sum of its elements. For exampl原创 2020-07-24 22:32:39 · 122 阅读 · 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 (氧化剂) must not be packed with flammable liquid (易燃液体), or it原创 2020-07-19 18:33:31 · 154 阅读 · 0 评论 -
1141 PAT Ranking of Institutions (25分)
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 contains one test case. For each case, the first line gives a原创 2020-07-19 15:19:24 · 159 阅读 · 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 the online programming assignments, and then receive a原创 2020-07-19 09:50:10 · 181 阅读 · 0 评论 -
1004 Counting Leaves (30分)
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case starts with a line containing 0<N<100, the number of nod原创 2020-07-18 18:30:03 · 134 阅读 · 0 评论 -
1003 Emergency (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 in each city and the length of each road between any pair of cities are marked原创 2020-07-18 18:28:53 · 106 阅读 · 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 information of a polynomial:K N1 aN1 N2 aN2原创 2020-07-18 18:26:54 · 121 阅读 · 0 评论 -
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 Specification:Each input file contains one test case. Each case contains a pair o原创 2020-07-18 18:24:53 · 169 阅读 · 0 评论 -
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 integer E such that it is for E days that one rides more than E miles. Eddington's own E原创 2020-07-18 18:16:47 · 139 阅读 · 0 评论 -
1140 Look-and-say Sequence (20分)
Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number. For example, the 2nd number means that there is o原创 2020-07-18 17:53:51 · 134 阅读 · 0 评论 -
1152 Google Recruitment (20分)
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 prime found in consecutive digits of the natural constant原创 2020-07-18 11:33:43 · 174 阅读 · 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 to see that Z can be devided by the product of A and B,原创 2020-07-18 10:50:42 · 134 阅读 · 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, column, or diagonal. The eight queens puzzle is an examp原创 2020-07-18 09:50:36 · 108 阅读 · 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 away gifts. Now you are supposed to help him generate t原创 2020-07-18 08:06:43 · 137 阅读 · 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 friend ID. Given some numbers, you are supposed to count原创 2020-07-17 23:17:16 · 113 阅读 · 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 as the following:0、 The Champion will receive a "Mystery原创 2020-07-17 23:04:26 · 186 阅读 · 0 评论 -
1113 Integer Set Partition (25分)
Given a set of N (>1) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1 and n2 numbers, respectively. Let S1 and S2 denote the sums of all the numbers in A1 and A2, respectively. You are原创 2020-07-17 22:00:00 · 161 阅读 · 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 resulting string on screen, you are supposed to list all the p原创 2020-07-17 20:50:12 · 173 阅读 · 0 评论 -
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 gives a positive integer N (≤20) which is the total number of nodes in the tree -- and henc原创 2020-07-17 16:44:45 · 134 阅读 · 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 their hobbies in common. You are supposed to find all the cl原创 2020-07-17 10:53:28 · 160 阅读 · 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) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4)原创 2020-07-16 23:44:55 · 236 阅读 · 1 评论 -
1106 Lowest 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 the chain buys products from one's supplier in a price P a原创 2020-07-16 22:02:52 · 118 阅读 · 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 a clockwise spiral. The matrix has m rows and n columns原创 2020-07-16 18:51:59 · 136 阅读 · 1 评论 -
1102 Invert 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 fuck off.Now it's your turn to prove that YOU CAN invert a binary tree!Input Specifi原创 2020-07-16 09:18:42 · 110 阅读 · 0 评论 -
1101 Quick Sort (25分)
There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its left and those larger than the pivot to its right. Given N原创 2020-07-16 07:49:26 · 123 阅读 · 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.Input Specification:Each input file contains one test case.原创 2020-07-15 08:42:49 · 161 阅读 · 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.Now given any string, you are supposed to tell the number of原创 2020-07-15 07:38:31 · 155 阅读 · 0 评论 -
PAT1090 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 the chain buys products from one's supplier in a price P a原创 2020-07-13 16:45:06 · 161 阅读 · 0 评论