![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT-Advanced Level
文章平均质量分 86
大山喵
这个作者很懒,什么都没留下…
展开
-
1075 PAT Judge (25 分)哈希表统计排序
题目The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file c...原创 2019-01-23 16:21:24 · 299 阅读 · 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 pe...原创 2018-12-24 11:24:34 · 312 阅读 · 0 评论 -
1065 A+B and C (64bit) (20 分)溢出判定
题目Given three integers A, B and C in [−263,263][−2^{63},2^{63}][−263,263], you are supposed to tell whether A+B>CA+B>CA+B>C.Input Specification:The first line of the input gives th...原创 2018-12-29 11:30:23 · 673 阅读 · 0 评论 -
1054 The Dominant Color (20 分)哈希表+map的运用
题目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 called th...原创 2018-12-23 22:40:54 · 357 阅读 · 0 评论 -
1053 Path of Equal Weight (30 分)
题目Given a non-empty tree with root R, and with weight WiW_iWi assigned to each tree node TiT_iTi. The weight of a path from R to L is defined to be the sum of the weights of all the nodes along the...原创 2018-12-23 22:33:14 · 420 阅读 · 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 right s...原创 2018-12-28 22:26:52 · 489 阅读 · 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 s...原创 2018-12-18 14:19:05 · 497 阅读 · 0 评论 -
1063 Set Similarity (25 分)求集合交集并集比值
题目Given two sets of integers, the similarity of the sets is defined to be Nc/Nt×100N_c/N_t\times 100%Nc/Nt×100, where NcN_cNc is the number of distinct common numbers shared by the two sets, and N...原创 2018-12-28 17:54:47 · 452 阅读 · 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 v...原创 2018-12-28 16:41:27 · 457 阅读 · 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 ...原创 2018-12-11 21:32:24 · 555 阅读 · 2 评论 -
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 is defined to b...原创 2018-12-11 20:47:39 · 1001 阅读 · 2 评论 -
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...原创 2018-12-28 11:22:05 · 581 阅读 · 1 评论 -
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 time. Different...原创 2018-12-11 16:22:48 · 1192 阅读 · 2 评论 -
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×1050.123×10^50.123×105 with simple chopping. Now given t...原创 2018-12-27 20:27:03 · 349 阅读 · 3 评论 -
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 with gamb...原创 2018-12-17 11:52:44 · 280 阅读 · 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][1,10^4][1,104]. The first ...原创 2018-12-17 10:26:01 · 230 阅读 · 0 评论 -
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 positi...原创 2018-12-18 18:58:09 · 751 阅读 · 1 评论 -
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 remaining pa...原创 2018-12-18 21:54:58 · 409 阅读 · 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 r...原创 2018-12-24 20:28:50 · 1258 阅读 · 3 评论 -
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...原创 2019-01-23 11:40:59 · 480 阅读 · 0 评论 -
1073 Scientific Notation (20 分)字符串处理——科学计数法
题目Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [±][1-9].[0-9]+E[±][0-9]+ which means that the int...原创 2019-01-22 22:54:45 · 475 阅读 · 0 评论 -
1078 Hashing (25 分)开放寻址法之二次探测
题目The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be H(key)=key%T...原创 2019-01-24 22:15:19 · 958 阅读 · 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 spea...原创 2019-01-08 21:02:07 · 376 阅读 · 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, the middle 2 ...原创 2018-12-04 19:07:35 · 198 阅读 · 0 评论 -
1077 Kuchiguse (20 分)字符串共同后缀
题目The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker’s personality. Such a preference is call...原创 2019-01-24 11:42:34 · 588 阅读 · 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. N...原创 2019-01-08 15:10:38 · 527 阅读 · 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 ta...原创 2019-01-08 11:25:43 · 647 阅读 · 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...原创 2019-01-23 20:46:28 · 325 阅读 · 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. Howev...原创 2019-01-07 22:57:08 · 1040 阅读 · 1 评论 -
1067 Sort with Swap(0, i) (25 分)贪心策略计算交换排序的最少次数
题目Given any permutation of the numbers {0, 1, 2,…, N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, ...原创 2019-01-07 20:22:33 · 436 阅读 · 0 评论 -
1066 Root of AVL Tree (25 分)AVL树
题目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...原创 2018-12-31 15:55:10 · 577 阅读 · 0 评论 -
1058 A+B in Hogwarts (20 分)混合进制
题目If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Hagrid explained it to Harry, “Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a ...原创 2018-12-24 22:15:25 · 345 阅读 · 0 评论 -
1057 Stack (30 分)树状数组求堆栈中位数
题目Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the top position) and...原创 2018-12-24 22:00:33 · 675 阅读 · 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 cont...原创 2018-12-19 11:53:24 · 1206 阅读 · 2 评论 -
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×⋯×pmkmN=p_1^{k_1} \times p_2^{k_2}\times ⋯\times p_m^{k_m}N=p1k1×p2k2×⋯...原创 2018-12-27 14:54:56 · 395 阅读 · 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 g...原创 2018-12-21 19:14:11 · 864 阅读 · 4 评论 -
1022 Digital Library (30)(30 分)
1 题目2 解题思路3 AC代码1 题目A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book ...原创 2018-08-08 21:34:39 · 890 阅读 · 1 评论 -
1019 General Palindromic Number (20)(20 分)
1 题目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 palindromic n...原创 2018-08-03 15:46:08 · 365 阅读 · 0 评论 -
1018 Public Bike Management (30)(30 分)
1 题目2 解题思路3 AC代码4 总结1 题目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 ...原创 2018-08-03 12:04:32 · 3334 阅读 · 0 评论 -
1017 Queueing at Bank (25)(25 分)
1 题目2 解题思路3 AC代码1 题目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 hav...原创 2018-08-02 21:22:31 · 432 阅读 · 2 评论