
PAT
coldfresh
那我们开始吧
展开
-
(pat)A1034. Head of a Gang
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...原创 2018-03-07 10:30:28 · 248 阅读 · 0 评论 -
(pat)A1064. Complete Binary Search Tree
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:1.The left subtree of a node contains only nodes with keys less than the node’s key. 2.The righ...原创 2018-03-12 19:12:49 · 354 阅读 · 0 评论 -
(pat)A1068. Find More Coins
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. However,...原创 2018-03-12 20:48:58 · 197 阅读 · 0 评论 -
(pat)A1020. Tree Traversals
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...原创 2018-03-05 20:45:50 · 196 阅读 · 0 评论 -
(pat)A1053 Path of Equal 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 to...原创 2018-03-05 21:57:46 · 184 阅读 · 0 评论 -
(pat)A1103. Integer Factorization
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 positive...原创 2018-03-13 16:50:09 · 335 阅读 · 0 评论 -
(pat)A1107. Social Clusters
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...原创 2018-03-13 17:50:18 · 286 阅读 · 0 评论 -
(pat)A1115. Counting Nodes in a BST
Counting Nodes in a BST (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A Binary Search Tree (BST) is recursively defined as a binary tree which has the following ...原创 2018-03-13 18:30:17 · 234 阅读 · 0 评论 -
(pat)A1043. Is It a Binary Search Tree
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:1.The left subtree of a node contains only nodes with keys less than the node’s key. 2.The righ...原创 2018-03-06 17:54:10 · 202 阅读 · 0 评论 -
(pat)A1119. Pre- and Post-order Traversals
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 ...原创 2018-03-14 09:56:47 · 354 阅读 · 0 评论 -
(pat)A1014. Waiting in Line
Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:1.The spa...原创 2018-03-10 16:25:26 · 267 阅读 · 0 评论 -
(pat)A1004. Counting Leaves
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. InputEach input file contains one test case. Each case starts with a line co...原创 2018-03-10 14:11:36 · 277 阅读 · 0 评论 -
(pat)A1076 Forwards on Weibo
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 a ...原创 2018-03-07 11:46:18 · 155 阅读 · 0 评论 -
(pat)A1003. Emergency
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l...原创 2018-03-07 14:20:40 · 225 阅读 · 0 评论 -
(pat)A1030. Travel Plan
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...原创 2018-03-07 18:29:07 · 222 阅读 · 0 评论 -
(pat)A1052. 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...原创 2018-03-04 19:45:01 · 175 阅读 · 0 评论 -
(pat)A1086. 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...原创 2018-03-08 23:03:39 · 198 阅读 · 0 评论 -
(pat)A1138. Postorder Traversal
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 se...原创 2018-03-09 09:39:58 · 355 阅读 · 0 评论 -
(pat)A1099. Build A Binary Search Tree
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 su...原创 2018-03-09 10:08:37 · 212 阅读 · 0 评论 -
(pat)A1059. Prime Factors
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 one test case ...原创 2018-03-09 11:40:37 · 235 阅读 · 0 评论 -
(pat)A1013. Battle Over Cities
It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we nee...原创 2018-03-09 11:57:27 · 236 阅读 · 0 评论 -
(pat)A1087. All Roads Lead to Rome
Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each ...原创 2018-03-10 13:37:26 · 432 阅读 · 0 评论 -
(pat)A1127. ZigZagging on a Tree
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 simple stand...原创 2018-03-14 12:03:08 · 307 阅读 · 0 评论