- 博客(60)
- 收藏
- 关注
原创 PAT甲级1151~1155|C++实现
PAT甲级1151 LCA in a Binary Tree (30分)|C++实现PAT甲级1152 Google Recruitment (20分)|C++实现PAT甲级1153 Decode Registration Card of PAT (25分)|C++实现PAT甲级1154 Vertex Coloring (25分)|C++实现PAT甲级1155 Heap Paths (30分)|C++实现...
2020-10-16 23:58:28 153
原创 PAT甲级1155 Heap Paths (30分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N (1<N≤1,000), the number of keys in the tree. Then the next line contains N distinct integer keys (all in the range of int)
2020-10-16 23:57:05 625
原创 PAT甲级1154 Vertex Coloring (25分)|C++实现
一、题目描述原题链接A proper vertex coloring is a labeling of the graph’s vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at most k colors is called a (proper) k-coloring.Now you are supposed to tell if a
2020-10-16 23:48:05 175
原创 PAT甲级1153 Decode Registration Card of PAT (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:8 4B123180908127 99B102180908003 86A112180318002 98T107150310127 62A107180908108 100T123180908010 78B112160918035 88A107180908021 981 A2 1073 1809082 999Sample Output:C
2020-10-16 23:35:51 133
原创 PAT甲级1152 Google Recruitment (20分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. Each case first gives in a line two positive integers: L (≤ 1,000) and K (< 10), which are the numbers of digits of the given number and the prime to be found, respectively. Then
2020-10-16 23:07:01 1608
原创 PAT甲级1151 LCA in a Binary Tree (30分)|C++实现
一、题目描述原题链接The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.Input Specification:Output Specification:S
2020-10-16 22:57:46 98
原创 PAT甲级1146~1150|C++实现
PAT甲级1146 Topological Order (25分)|C++实现PAT甲级1147 Heaps (30分)|C++实现PAT甲级1148 Werewolf - Simple Version (20分)|C++实现PAT甲级1149 Dangerous Goods Packaging (25分)|C++实现PAT甲级1150 Travelling Salesman Problem (25分)|C++实现...
2020-10-15 23:31:22 112
原创 PAT甲级1150 Travelling Salesman Problem (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:6 106 2 13 4 11 5 12 5 13 1 84 1 61 6 16 3 11 2 14 5 177 5 1 4 3 6 2 57 6 1 3 4 5 2 66 5 1 4 3 6 29 6 2 1 6 3 4 5 2 64 1 2 5 17 6 1 2 5 4 3 17 6 3 2 5 4 1 6Sample
2020-10-15 23:29:32 146
原创 PAT甲级1149 Dangerous Goods Packaging (25分)|C++实现
一、题目描述原题链接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 (易
2020-10-15 23:14:46 317
原创 PAT甲级1148 Werewolf - Simple Version (20分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input 1:5-2+3-4+5+4Sample Output 1:1 4Sample Input 2:6+6+3+1-5-2+4Sample Output 2(the solution is not unique):1 5Sample Input 3:5-2-3-4-5-1Sample Output 3:No Solu
2020-10-15 10:44:51 140
原创 PAT甲级1147 Heaps (30分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:3 898 72 86 60 65 12 23 508 38 25 58 52 82 70 6010 28 15 12 34 9 8 56Sample Output:Max Heap50 60 65 72 12 23 86 98Min Heap60 58 52 38 82 70 25 8Not Heap56 12 34 28 9 8 15 1
2020-10-15 10:30:01 113
原创 PAT甲级1146 Topological Order (25分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. For each case, the first line gives two positive integers N (≤ 1,000), the number of vertices in the graph, and M (≤ 10,000), the number of directed edges. Then M lines follow, each
2020-10-15 10:13:56 103
原创 PAT甲级1141~1145|C++实现
PAT甲级1141 PAT Ranking of Institutions (25分)|C++实现PAT甲级1142 Maximal Clique (25分)|C++实现PAT甲级1143 Lowest Common Ancestor (30分)|C++实现PAT甲级1144 The Missing Number (20分)|C++实现PAT甲级1145 Hashing - Average Search Time (25分)|C++实现...
2020-10-14 19:08:44 107
原创 PAT甲级1145 Hashing - Average Search Time (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:4 5 410 6 4 15 1111 4 15 2Sample Output:15 cannot be inserted.2.8二、解题思路考察了哈希表解决冲突的平方探测法,按照题目给的步骤进行模拟即可,代码比较易读,详情见代码注释。三、AC代码#include<iostream>#include<cstdio>#
2020-10-14 19:07:04 75
原创 PAT甲级1144 The Missing Number (20分)|C++实现
一、题目描述原题链接Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Output Specification:Print in a line the smallest positive integer that is missing from the input list.Sample Inpu
2020-10-14 18:56:59 90
原创 PAT甲级1143 Lowest Common Ancestor (30分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:6 86 3 1 2 5 4 8 72 58 71 912 -30 899 99Sample Output:LCA of 2 and 5 is 3.8 is an ancestor of 7.ERROR: 9 is not found.ERROR: 12 and -3 are not found.ERROR: 0 is not foun
2020-10-14 18:47:56 102
原创 PAT甲级1142 Maximal Clique (25分)|C++实现
一、题目描述原题链接A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adjacent vertex.(Quoted from https://en.wikipe
2020-10-14 18:26:04 95
原创 PAT甲级1141 PAT Ranking of Institutions (25分)|C++实现
一、题目描述原题链接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:Output Specification:Sample Input:10A57908 85 AuB57908 54 L
2020-10-14 18:14:50 108
原创 PAT甲级1136~1140|C++实现
PAT甲级1136 A Delayed Palindrome (20分)|C++实现PAT甲级1137 Final Grading (25分)|C++实现PAT甲级1138 Postorder Traversal (25分)|C++实现PAT甲级1139 First Contact (30分)|C++实现PAT甲级1140 Look-and-say Sequence (20分)|C++实现
2020-10-13 22:16:53 110
原创 PAT甲级1140 Look-and-say Sequence (20分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case, which gives D (in [0, 9]) and a positive integer N (≤ 40), separated by a space.Output Specification:Print in a line the Nth number in a look-and-say sequence of D.Sample Input:
2020-10-13 22:14:47 135
原创 PAT甲级1139 First Contact (30分)|C++实现
一、题目描述原题链接Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instead, he might ask ano
2020-10-13 13:03:37 525
原创 PAT甲级1138 Postorder Traversal (25分)|C++实现
一、题目描述原题链接Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal sequence of the corresponding binary tree.Inp
2020-10-13 12:23:50 99
原创 PAT甲级1137 Final Grading (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:6 6 701234 880a1903 199ydjh2 200wehu8 300dx86w 220missing 400ydhfu77 99wehu8 55ydjh2 98dx86w 88a1903 8601234 39ydhfu77 88a1903 6601234 58wehu8 84ydjh2 82missing 99
2020-10-13 11:46:46 114
原创 PAT甲级1136 A Delayed Palindrome (20分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case which gives a positive integer no more than 1000 digits.Output Specification:Sample Input 1:97152Sample Output 1:97152 + 25179 = 122331122331 + 133221 = 255552255552 is a pa
2020-10-13 10:48:10 185
原创 PAT甲级1131~1135|C++实现
PAT甲级1131 Subway Map (30分)|C++实现PAT甲级1132 Cut Integer (20分)|C++实现PAT甲级1133 Splitting A Linked List (25分)|C++实现PAT甲级1134 Vertex Cover (25分)|C++实现PAT甲级1135 Is It A Red-Black Tree (30分)|C++实现
2020-10-12 23:13:23 114
原创 PAT甲级1135 Is It A Red-Black Tree (30分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:For each test case, print in a line “Yes” if the given tree is a red-black tree, or “No” if not.Sample Input:397 -2 1 5 -4 -11 8 14 -15911 -2 1 -7 5 -4 8 14 -15810 -7 5 -6 8 15 -11 17Sampl
2020-10-12 23:09:16 128
原创 PAT甲级1134 Vertex Cover (25分)|C++实现
一、题目描述原题链接Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Output Specification:Sample Input:10 118 76 84 58 48 11
2020-10-12 09:48:40 138
原创 PAT甲级1133 Splitting A Linked List (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:For each case, output in order (from beginning to the end of the list) the resulting linked list. Each node occupies a line, and is printed in the same format as in the input.Sample Input:00100 9
2020-10-12 09:33:48 89
原创 PAT甲级1132 Cut Integer (20分)|C++实现
一、题目描述原题链接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
2020-10-12 09:15:54 82
原创 PAT甲级1131 Subway Map (30分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:47 1001 3212 1003 1204 1005 1306 77979 9988 2333 1204 2006 2005 2004 2003 2302 200113 3011 3812 3013 3001 1306 3003 2333 3066 3212 3008 2302 3010 30114 6666 8432 4011 130633011
2020-10-12 09:06:01 111
原创 PAT甲级1126~1130|C++实现
PAT甲级1126 Eulerian Path (25分)|C++实现PAT甲级1127 ZigZagging on a Tree (30分)|C++实现PAT甲级1128 N Queens Puzzle (20分)|C++实现PAT甲级1129 Recommendation System (25分)|C++实现PAT甲级1130 Infix Expression (25分)|C++实现
2020-10-09 23:50:20 1849
原创 PAT甲级1130 Infix Expression (25分)|C++实现
一、题目描述原题链接Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Output Specification:For each case, print in a line the infix ex
2020-10-09 23:48:33 207
原创 PAT甲级1129 Recommendation System (25分)|C++实现
一、题目描述原题链接Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that rates the user’s preference by the number of times that an item has been accessed by this use
2020-10-09 23:34:33 139
原创 PAT甲级1128 N Queens Puzzle (20分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:For each configuration, if it is a solution to the N queens problem, print YES in a line; or NO if not.Sample Input:48 4 6 8 2 7 1 3 59 4 6 7 2 8 1 9 5 36 1 5 2 6 4 35 1 3 5 2 4Sample Output
2020-10-09 22:54:46 118
原创 PAT甲级1127 ZigZagging on a Tree (30分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N (≤30), the total number of nodes in the binary tree. The second line gives the inorder sequence and the third line gives the
2020-10-09 22:35:20 177
原创 PAT甲级1126 Eulerian Path (25分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. Each case starts with a line containing 2 numbers N (≤ 500), and M, which are the total number of vertices, and the number of edges, respectively. Then M lines follow, each describes
2020-10-09 22:08:31 138
原创 PAT甲级1121~1125|C++实现
PAT甲级1121 Damn Single (25分)|C++实现PAT甲级1122 Hamiltonian Cycle (25分)|C++实现(非原创)PAT甲级1123 Is It a Complete AVL Tree (30分)|C++实现PAT甲级1124 Raffle for Weibo Followers (20分)|C++实现PAT甲级1125 Chain the Ropes (25分)|C++实现...
2020-10-08 22:53:30 212
原创 PAT甲级1125 Chain the Ropes (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:810 15 12 3 4 13 1 15Sample Output:14二、解题思路利用了贪心的思想,两条绳子要连起来,形成的新绳子的长度就是原来两段绳子之和的一半。现在给我们一些不同长度的绳子,要怎么样获得最长长度的绳子呢?考虑长度为1和15的两条绳子,得到的新绳子长度为8,那么与之前较长的绳子15的长度差就非常大,我们可以理解成绳子“损失”了,而
2020-10-08 22:46:35 136
原创 PAT甲级1124 Raffle for Weibo Followers (20分)|C++实现
一、题目描述原题链接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
2020-10-08 22:33:50 155
原创 (非原创)PAT甲级1123 Is It a Complete AVL Tree (30分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. For each case, the first line contains a positive integer N (≤ 20). Then N distinct integer keys are given in the next line. All the numbers in a line are separated by a space.Out
2020-10-08 21:58:41 702
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人