
PAT (Advanced Level)
文章平均质量分 81
i逆天耗子丶
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
PAT - 甲级 - 1002. A+B for Polynomials (25)
This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polyn原创 2016-07-02 23:36:39 · 583 阅读 · 0 评论 -
PAT - 甲级 - 1008. Elevator (20)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 order. It costs 6 sec原创 2016-07-02 20:50:26 · 513 阅读 · 0 评论 -
PAT - 甲级 - 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 the continuous subsequen...原创 2016-07-02 20:45:33 · 560 阅读 · 0 评论 -
PAT - 甲级 - 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's and out's, you原创 2016-07-02 20:39:39 · 475 阅读 · 0 评论 -
PAT - 甲级 - 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 test case.原创 2016-07-02 20:35:43 · 2830 阅读 · 0 评论 -
PAT - 甲级 - 1116. Come on! Let's C (20) (桶排思想)
"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny as原创 2016-12-08 09:35:27 · 984 阅读 · 0 评论 -
PAT - 甲级 - 1117. Eddington Number(25) (题意理解)
British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- that is, the maximum integer E such that it is for E原创 2016-12-08 09:43:19 · 2333 阅读 · 4 评论 -
PAT - 甲级 - 1119. Pre- and Post-order Traversals (30) (递归建树)
Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences, or preorder and inorder原创 2016-12-08 16:45:41 · 685 阅读 · 0 评论 -
PAT - 甲级 - 1113. Integer Set Partition (25) (排序)
Given a set of N (> 1) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1 and n2 numbers, respectively. Let S1 and S2 denote the sums of all the numbers in原创 2016-12-09 11:38:47 · 596 阅读 · 0 评论 -
PAT - 甲级 - 1107. Social Clusters (30) (并查集)
When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A "social cluster" is a set of people who have some of th原创 2016-12-09 20:10:25 · 518 阅读 · 0 评论 -
PAT - 甲级 - 1114. Family Property (25) (并查集)
This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each f原创 2016-12-09 12:14:11 · 668 阅读 · 0 评论 -
PAT - 甲级 - 1103. Integer Factorization (30)(dfs回溯+减枝)
题目描述:The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K-P factorization of N for any原创 2017-03-30 22:01:06 · 605 阅读 · 0 评论 -
PAT - 甲级 - 1106. Lowest Price in Supply Chain (25)(多叉树)
题目描述: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, every原创 2017-03-30 16:44:05 · 465 阅读 · 0 评论 -
PAT - 甲级 - 1104. Sum of Number Segments (20)(逻辑题)
题目描述:Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence {0.1, 0.2, 0.3, 0.4}, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0原创 2017-03-30 10:31:52 · 618 阅读 · 0 评论 -
PAT - 甲级 - 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 sequence o原创 2017-03-30 09:59:10 · 785 阅读 · 0 评论 -
PAT - 甲级 - 1127. ZigZagging on a Tree (30) ( 树的层次遍历变形 )
题目描述:Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences. And it is a sim原创 2017-03-23 15:37:54 · 767 阅读 · 0 评论 -
PAT - 甲级 - 1112. Stucked Keyboard (20) (STL - vector)
题目描述: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原创 2017-03-29 22:51:39 · 830 阅读 · 0 评论 -
PAT - 甲级 - 1124. Raffle for Weibo Followers (20)
题目描述: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,原创 2017-03-28 22:21:25 · 669 阅读 · 0 评论 -
PAT - 甲级 - 1125. Chain the Ropes (25)
题目描述:Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the figure. The resul原创 2017-03-28 22:23:39 · 498 阅读 · 0 评论 -
PAT - 甲级 - 1126. Eulerian Path (25)
题目描述:In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They原创 2017-03-28 23:27:48 · 557 阅读 · 0 评论 -
PAT - 甲级 - 1115. Counting Nodes in a BST (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 or equal to the no原创 2017-03-29 10:59:15 · 413 阅读 · 0 评论 -
PAT - 甲级 - 1122. Hamiltonian Cycle (25)
题目描述:The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a "Hamiltonian cycle".In this problem, you are supposed to tell if a g原创 2017-03-28 21:51:49 · 1439 阅读 · 0 评论 -
PAT - 甲级 - 1123. Is It a Complete AVL Tree (30)
题目描述: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, rebal原创 2017-03-28 22:06:42 · 599 阅读 · 0 评论 -
PAT - 甲级 - 1120. Friend Numbers (20)
Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are friend numbers since 1+2+3 = 5+1 = 6, and 6 is their原创 2016-12-13 13:16:54 · 438 阅读 · 0 评论 -
PAT - 甲级 - 1130. Infix Expression (25) (中序遍历)
题目描述:Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification: Each input原创 2017-03-19 13:13:21 · 1708 阅读 · 0 评论 -
PAT - 甲级 - 1109. Group Photo (25)
Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following:The number of people in each row must be N/K (round down to the nearest inte原创 2017-02-26 14:49:40 · 443 阅读 · 0 评论 -
PAT - 甲级 - 1121. Damn Single (25)
"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 inp原创 2016-12-13 13:18:33 · 703 阅读 · 0 评论 -
PAT - 甲级 - 1102. Invert a Binary Tree (25)(中序遍历,层次遍历)
题目描述:The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off.Now it's your原创 2017-03-30 22:14:27 · 543 阅读 · 0 评论 -
PAT - 甲级 - 1099. Build A 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.T原创 2017-03-30 23:13:11 · 1182 阅读 · 0 评论 -
PAT - 甲级 - 1100. Mars Numbers (20)(字符串处理)
题目描述:People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars. The numbers 1 to 12 on Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec"原创 2017-03-30 23:48:01 · 876 阅读 · 0 评论 -
【索引】PAT甲级题解
1001 A+B Format (20)1002 A+B for Polynomials (25)1003 Emergency (25)1004 Counting Leaves (30)1005 Spell It Right (20)1006 Sign In and Sign Out (25)1007 Maximum Subsequ原创 2017-03-29 09:49:28 · 1345 阅读 · 0 评论 -
PAT - 甲级 - 1043. Is It a Binary Search Tree (25)(递归建树,求后序,BST)
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 rig原创 2017-11-07 10:28:00 · 276 阅读 · 0 评论 -
PAT - 甲级 - 1034. Head of a Gang (30)(DFS求连通块)
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 be t原创 2017-11-06 13:06:26 · 308 阅读 · 0 评论 -
PAT - 甲级 - 1021. Deepest Root (25)(DFS图的连通分量,最大深度)
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 tree. Such a root原创 2017-11-05 11:51:09 · 451 阅读 · 0 评论 -
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. The rig原创 2017-11-09 14:05:56 · 375 阅读 · 0 评论 -
PAT - 甲级 - 1079. Total Sales of Supply Chain (25)(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原创 2017-11-10 12:00:30 · 298 阅读 · 0 评论 -
PAT - 甲级 - 1072. Gas Station (30)(Dijkstra)
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou原创 2017-11-02 14:08:47 · 448 阅读 · 0 评论 -
PAT - 甲级 - 1128. N Queens Puzzle (20) (8皇后问题变形)
题目描述:The "eight queens puzzle" is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the s原创 2017-03-19 12:12:45 · 2144 阅读 · 1 评论 -
PAT - 甲级 - 1086. Tree Traversals Again (25)(已知中序+先序求后序)
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原创 2017-11-11 14:32:16 · 299 阅读 · 0 评论 -
PAT - 甲级 - 1090. Highest Price in Supply Chain (25)(树的遍历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原创 2017-11-12 10:49:12 · 289 阅读 · 0 评论