pat(甲)算法题库刷题代码
文章平均质量分 77
计算机程序设计能力考试。此分栏备份自己刷pat三遍后的最终代码,三遍刷完后秋季考试考到93分。
现在pat成绩不能抵浙大机试了,用于新手配合算法笔记学刷题还是有点用的。
程序员小海绵【vincewm】
本科毕业于西安某211电子信息类专业,Java高级工程师,CSDN博客专家,Java领域优质创作者,专注于Java领域知识分享
展开
-
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 Specificatio...原创 2019-12-26 15:22:40 · 57 阅读 · 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 contain...原创 2019-12-26 15:22:03 · 61 阅读 · 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 ea...原创 2019-12-26 15:21:26 · 58 阅读 · 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. Eac...原创 2019-12-26 15:20:44 · 72 阅读 · 0 评论 -
1005 Spell It Right (20分)
题目地址Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one t...原创 2019-12-26 15:20:15 · 72 阅读 · 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...原创 2019-12-26 15:19:49 · 68 阅读 · 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 t...原创 2019-12-26 15:19:22 · 51 阅读 · 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 orde...原创 2019-12-26 15:16:57 · 58 阅读 · 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 o...原创 2019-12-26 15:15:30 · 68 阅读 · 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...原创 2019-12-26 15:15:04 · 80 阅读 · 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 Algr...原创 2019-12-26 15:14:33 · 60 阅读 · 0 评论 -
1013 Battle Over Cities (25分)
题目地址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 imme...原创 2019-12-26 15:13:32 · 64 阅读 · 0 评论 -
1014 Waiting in Line (30分)
题目地址Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in lin...原创 2019-12-26 15:12:55 · 50 阅读 · 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 revers...原创 2019-12-26 15:12:10 · 57 阅读 · 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 cal...原创 2019-12-26 15:11:43 · 51 阅读 · 0 评论 -
1017 Queueing at Bank (25分)
题目地址Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line beh...原创 2019-12-26 15:11:16 · 53 阅读 · 0 评论 -
1018 Public Bike Management (30分)
题目地址There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other...原创 2019-12-26 15:10:30 · 70 阅读 · 0 评论 -
1019 General Palindromic Number (20分)
题目地址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 pa...原创 2019-12-26 15:09:10 · 51 阅读 · 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 se...原创 2019-12-26 15:08:30 · 64 阅读 · 0 评论 -
1021 Deepest Root (25分)
题目地址A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest t...原创 2019-12-26 15:08:04 · 55 阅读 · 0 评论 -
1022 Digital Library (30分)
题目地址A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique...原创 2019-12-26 15:07:37 · 60 阅读 · 0 评论 -
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 happens to be another 9...原创 2019-12-26 15:07:07 · 87 阅读 · 0 评论 -
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 pa...原创 2019-12-26 15:06:40 · 66 阅读 · 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, an...原创 2019-12-26 15:06:05 · 52 阅读 · 0 评论 -
1026 Table Tennis (30分)
题目地址A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be as...原创 2019-12-26 15:05:25 · 71 阅读 · 0 评论 -
1027 Colors in Mars (20分)
题目地址People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red,...原创 2019-12-26 15:04:58 · 60 阅读 · 0 评论 -
1028 List Sorting (25分)
题目地址Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line...原创 2019-12-26 15:04:28 · 46 阅读 · 0 评论 -
1029 Median (25分)
题目地址Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10...原创 2019-12-26 15:03:58 · 62 阅读 · 0 评论 -
1030 Travel Plan (30分)
题目地址A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide th...原创 2019-12-26 15:03:23 · 54 阅读 · 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...原创 2019-12-26 15:02:48 · 64 阅读 · 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 suf...原创 2019-12-26 15:02:13 · 60 阅读 · 0 评论 -
1033 To Fill or Not to Fill (25分)
题目地址With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to t...原创 2019-12-26 15:01:22 · 88 阅读 · 0 评论 -
1034 Head of a Gang (30分)
题目地址One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation i...原创 2019-12-26 15:00:49 · 55 阅读 · 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...原创 2019-12-26 15:00:17 · 60 阅读 · 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 c...原创 2019-12-26 14:59:48 · 51 阅读 · 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 ...原创 2019-12-26 14:59:17 · 51 阅读 · 0 评论 -
1038 Recover the Smallest Number (30分)
题目地址Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like...原创 2019-12-26 14:58:43 · 56 阅读 · 0 评论 -
1039 Course List for Student (25分)
题目地址Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each s...原创 2019-12-26 14:58:13 · 54 阅读 · 0 评论 -
1040 Longest Symmetric String (25分)
题目地址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&...原创 2019-12-26 14:57:35 · 48 阅读 · 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 fi...原创 2019-12-26 14:57:06 · 58 阅读 · 0 评论