PAT甲级练习题
文章平均质量分 76
知了声日迟
这个作者很懒,什么都没留下…
展开
-
PAT甲级 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.原创 2017-11-22 14:11:03 · 212 阅读 · 0 评论 -
PAT甲级 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 the shor原创 2017-11-04 20:05:45 · 153 阅读 · 0 评论 -
PAT甲级 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.原创 2017-11-14 13:45:11 · 222 阅读 · 0 评论 -
PAT甲级 1047. Student List for Course (25)
题目:Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.原创 2017-11-14 12:58:34 · 238 阅读 · 0 评论 -
PAT甲级 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 inp原创 2017-11-13 21:59:41 · 173 阅读 · 0 评论 -
PAT甲级 1045. Favorite Color Stripe (30)
题目: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 remain原创 2017-11-13 21:19:32 · 174 阅读 · 0 评论 -
PAT甲级 1044. Shopping in Mars (25)
题目:Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any原创 2017-11-13 17:27:15 · 215 阅读 · 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.原创 2017-11-13 11:31:06 · 147 阅读 · 0 评论 -
PAT甲级 1028. List Sorting (25)
题目:Excel can sort records according to any column. Now you are supposed to imitate this function.InputEach input file contains one test case. For each case, the first line contains two i原创 2017-10-25 21:38:26 · 164 阅读 · 0 评论 -
PAT甲级 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, 15, 16, 17} i原创 2017-10-25 20:47:53 · 178 阅读 · 0 评论 -
PAT甲级 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 ra原创 2017-10-16 19:33:50 · 147 阅读 · 0 评论 -
PAT甲级 1042. Shuffling Machine (20)
题目:Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate w原创 2017-11-09 19:33:32 · 137 阅读 · 0 评论 -
PAT甲级 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 m原创 2017-11-04 20:58:58 · 203 阅读 · 0 评论 -
PAT甲级 1049. Counting Ones (30)
题目:The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there are f原创 2017-11-14 16:01:09 · 173 阅读 · 0 评论 -
PAT甲级 1063. Set Similarity (25)
题目:Given two sets of integers, the similarity of the sets is defined to be Nc/Nt*100%, where Nc is the number of distinct common numbers shared by the two sets, and Nt is the total number of d原创 2017-11-21 13:42:18 · 193 阅读 · 0 评论 -
PAT甲级 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原创 2017-11-21 12:52:22 · 204 阅读 · 0 评论 -
PAT甲级 1061. Dating (20)
题目:Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange stri原创 2017-11-21 11:07:24 · 234 阅读 · 0 评论 -
PAT甲级 1060. Are They Equal (25)
题目:If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123*105 with simple chopping. Now given the number of原创 2017-11-21 09:57:48 · 215 阅读 · 0 评论 -
PAT甲级 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 = p1^k1 * p2^k2 *…*pm^km.Input Specification:Each input file contains o原创 2017-11-20 17:21:31 · 222 阅读 · 0 评论 -
PAT甲级 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原创 2017-11-15 15:03:47 · 181 阅读 · 0 评论 -
PAT甲级 1054. The Dominant Color (20)
题目:Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is cal原创 2017-11-15 13:33:28 · 189 阅读 · 0 评论 -
PAT甲级 1053. Path of Equal Weight (30)
题目:Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to Lis defined to be the sum of the weights of all the nodes along the path原创 2017-11-15 10:50:34 · 178 阅读 · 0 评论 -
PAT甲级 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.原创 2017-11-15 10:18:08 · 169 阅读 · 0 评论 -
PAT甲级 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 sequ原创 2017-11-14 18:20:04 · 273 阅读 · 0 评论 -
PAT甲级 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 given strings.原创 2017-11-14 16:28:35 · 184 阅读 · 0 评论 -
PAT甲级 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原创 2017-11-09 18:50:55 · 200 阅读 · 0 评论 -
PAT甲级 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&TAP s", hence原创 2017-11-09 17:11:37 · 162 阅读 · 0 评论 -
PAT 甲级 1011. World Cup Betting (20)
题目: 点击打开链接思路:比较简单 1.输入数据,选择记录每一行中的最大值; 2.根据每一行中的最大值,判断输出对应的字母; 3.将每一行中的最大值genuine公式进行计算,结果保留两位小数输出。疑惑: 题目里测试案例给出的答案是37.98,实际计算结果是37.975。这样的例子说明保留两位小原创 2017-07-28 13:37:47 · 226 阅读 · 0 评论 -
PAT 甲级 1010.Radix (25)
题目:点击打开链接思路: 1.当未知radix的数只有一位时,才会有多种情况,其他均为一种情况(测试点0就是这样); 2.数值可能会很大,计算应采用long long类型; 3.radix的取值范围应是从 未知radix数中的最大数字加1 到 已知radix数的值,而不是简单的 未知radix数中的最大数字加1 到 36;原创 2017-07-28 12:59:04 · 276 阅读 · 0 评论 -
PAT 甲级 1017. Queueing at Bank (25)
题目:点击打开链接思路:1.在输入时,可将达到时间晚于17:00:00的客户排除,不计入名单; 2.先根据到达时间排序,将情况分为前K位和后K位(K为窗口数)达到两个部分: 1)对前K位达到,若在8:00:00前达到,则等待时间则为其到8:00:00的时间,这里的服务时间是8:00:00,若在8:00:00后到达则无等待时间,这里的服务原创 2017-08-12 19:39:50 · 225 阅读 · 0 评论 -
PAT 甲级 1016. Phone Bills (25)
题目:点击打开链接思路:1.根据输入,将通话信息根据用户名、时间进行排序 2.排序完后,进行信息筛选:在计算单次通话话费时,先判断两条信息是否属于同一用户,再判断其是否为一on-line ,一off-line的情况; 3.在计算话费时,注意时间跨度代码:#include#include#include#include#incl原创 2017-08-12 17:30:19 · 163 阅读 · 0 评论 -
PAT 1008. Elevator (20)
题目:https://www.patest.cn/contests/pat-a-practise/1008思路:判断一下是否上升,然后按题意计算即可代码:#includeusing namespace std;int main(){ int floor[100]; int sum=0; int stay=5; int N; cin>>N; int i; for(原创 2017-07-26 19:50:19 · 233 阅读 · 0 评论 -
PAT 1007. Maximum Subsequence Sum (25)
题目:点击打开链接思路:在输入的时候就记录第一个非负数和最后一个非负数的位置。把序列分为全为非负数和不全为非负数两种情况: 1.全为非负数,根据题目要求输出sum为0,以及第一个和最后一个数字; 2.不全为非负数,利用遍历选择。注意:要考虑到数字为0的情况代码:#include#includeusing namespace s原创 2017-07-26 19:23:25 · 139 阅读 · 0 评论 -
1001. A+B Format (20)
1001. A+B Format (20)原创 2017-07-19 16:00:11 · 185 阅读 · 0 评论 -
1002. A+B for Polynomials (25)
1002. A+B for Polynomials (25) 思路及代码原创 2017-07-19 18:48:38 · 362 阅读 · 0 评论 -
PAT甲级练习题1003
采用深度优先搜索。#include#include#includeusing namespace std;//采用深度优先搜索int minlen=INT_MAX; //最短路径int num; //路径数int maxteam; //最大的救援队数量int N; //节点总数int Le原创 2017-07-23 17:52:07 · 835 阅读 · 0 评论 -
PAT 1013. Battle Over Cities (25)
题目:1013. Battle Over Cities (25)思路:1. 利用并查集,剔除掉选中城市的道路,构建无向联通图。通过代表元的个数来计算需要搭建的道路数。 2.利用深度优先搜索。代码:并查集#include#includeusing namespace std;struct road{ int x,y;};//初始化根节点void原创 2017-07-31 19:18:11 · 160 阅读 · 0 评论 -
PAT 1015. Reversible Primes (20)
题目:1015. Reversible Primes (20)思路:1.由于N 2.以N注意: 在本次题目中,我选择使用质数表,但并未给0,1 标注为不是质数,导致测试点2通不过,即忽略了 reversible number 等于1的情况(如输入2,2 ,则reversible number为1)。代码:#includeusin原创 2017-07-31 16:00:19 · 298 阅读 · 0 评论 -
PAT 甲级 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 s原创 2017-08-13 14:44:01 · 270 阅读 · 0 评论 -
PAT 甲级1019. General Palindromic Number (20)
题目:点击打开链接思路:简单的进制转换,考虑单个数字情况。代码:#include#include#includeusing namespace std;int main(){ long long N; int b; cin>>N>>b; vector k; while(N>=b) { k.push_back(N%b); N/=b; } k.push_原创 2017-08-13 15:24:02 · 181 阅读 · 0 评论