![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT甲级
Oliver_H_
这个作者很懒,什么都没留下…
展开
-
1001 A+B Format(字符串+to_string)
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 fil...原创 2019-08-02 22:59:50 · 130 阅读 · 0 评论 -
1094 The Largest Generation(DFS+height)
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 S...原创 2019-08-26 21:18:46 · 86 阅读 · 0 评论 -
1030 Travel Plan(经典Dijkstra+DFS)
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 shortest path b...原创 2019-08-30 18:12:39 · 224 阅读 · 0 评论 -
1071 Speech Patterns(map+cctype+auto)
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 speaker...原创 2019-08-31 14:41:47 · 80 阅读 · 0 评论 -
1084 Broken Keyboard(字符串+find)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen. Now given a string that you are supposed to ...原创 2019-08-31 17:16:06 · 86 阅读 · 0 评论 -
1086 Tree Traversals Again(数的遍历+栈+字符串数字混合输入)
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-09-02 13:50:19 · 111 阅读 · 0 评论 -
1089 Insert or Merge(InsertionSort+MergeSort,18/25)
According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, ...原创 2019-09-02 21:28:09 · 186 阅读 · 0 评论 -
1090 Highest Price in Supply Chain(DFS)
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...原创 2019-09-03 11:38:59 · 118 阅读 · 0 评论 -
1115 Counting Nodes in a BST(建BST+DFS)
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 or equal to the node’s key. Th...原创 2019-09-03 17:04:59 · 98 阅读 · 0 评论 -
1100 Mars Numbers(字符串+stoi)
People on Mars count their numbers with base 13: Zero on Earth is called “tret” on Mars. The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, re...原创 2019-09-04 10:51:39 · 124 阅读 · 0 评论 -
1124 Raffle for Weibo Followers(map)
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 ...原创 2019-09-04 16:22:14 · 110 阅读 · 0 评论 -
1112 Stucked Keyboard(map+set)
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 resulti...原创 2019-09-05 11:27:51 · 112 阅读 · 0 评论 -
1121 Damn Single(vector+set)
“Damn Single (单身狗)” is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of. Input Specification: Each input ...原创 2019-09-05 17:11:33 · 100 阅读 · 0 评论 -
1137 Final Grading(vector+map)
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...原创 2019-09-06 11:20:03 · 126 阅读 · 0 评论 -
1141 PAT Ranking of Institutions(map+vector+tolower+结构体+sort)
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 contain...原创 2019-09-06 15:15:02 · 106 阅读 · 0 评论 -
1079 Total Sales of Supply Chain(DFS+height+v.resize(n))
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...原创 2019-08-26 18:10:33 · 119 阅读 · 0 评论 -
1004 Counting Leaves(DFS+height)
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 w...原创 2019-08-26 10:38:44 · 100 阅读 · 0 评论 -
1005 Spell It Right(字符串+to_string)
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 test case. Each ...原创 2019-08-04 23:27:10 · 68 阅读 · 0 评论 -
1015 Reversible Primes(素数判断+进制转换)
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-08-05 23:04:56 · 88 阅读 · 0 评论 -
1050 String Subtraction(字符串+getline)
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. However, it mi...原创 2019-08-13 13:41:34 · 136 阅读 · 0 评论 -
1061 Dating(cctype)
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 strings...原创 2019-08-13 19:47:34 · 136 阅读 · 0 评论 -
1065 A+B and C (64bit)(longlong取值范围问题)
Given three integers A, B and C in [−2 ^63,2 ^63], you are supposed to tell whether A+B>C. Input Specification: The first line of the input gives the positive number of test cases, T (≤10). Then ...原创 2019-08-14 18:32:48 · 134 阅读 · 0 评论 -
1069 The Black Hole of Numbers(字符串的处理!最重要字符串题之一!)
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...原创 2019-08-14 20:11:14 · 95 阅读 · 0 评论 -
1031 Hello World for U(模拟题+memset)
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 d e l l r lowo That is, the characters must be pr...原创 2019-08-11 11:59:53 · 106 阅读 · 0 评论 -
1035 Password(字符串+vector代替结构体)
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 ...原创 2019-08-11 20:45:02 · 78 阅读 · 0 评论 -
1073 Scientific Notation(字符串下标和字符个数的问题,多思考几次,不要乱)
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 intege...原创 2019-08-15 20:07:01 · 125 阅读 · 0 评论 -
1042 Shuffling Machine(数组元素调换+字符数字拼接)
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 gambler...原创 2019-08-12 21:11:59 · 73 阅读 · 0 评论 -
1032 Sharing(链表,结构体)
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 suffix. For example,...原创 2019-08-16 19:24:43 · 98 阅读 · 0 评论 -
1052 Linked List Sorting(链表,结构体)
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 give...原创 2019-08-16 21:01:33 · 118 阅读 · 0 评论 -
1053 Path of Equal Weight(DFS+weight)
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 L is defined to be the sum of the weights of all the nodes along the path from R ...原创 2019-08-26 09:14:44 · 152 阅读 · 0 评论 -
1020 Tree Traversals(in+post->level order)
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 sequence of the cor...原创 2019-08-26 09:35:13 · 254 阅读 · 0 评论 -
1118 Birds in Forest(并查集)
Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the scientists to count the maxi...原创 2019-09-07 14:01:20 · 114 阅读 · 0 评论