pat甲级
暖i
这个作者很懒,什么都没留下…
展开
-
1103 Integer Factorizatio
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...原创 2020-02-15 21:46:51 · 160 阅读 · 0 评论 -
1095 Cars on Campus
Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you a...原创 2020-02-13 20:16:16 · 129 阅读 · 0 评论 -
1078 Hashing
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%TSiz...原创 2020-02-06 21:18:54 · 90 阅读 · 0 评论 -
1076 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 ...原创 2020-02-05 20:25:04 · 121 阅读 · 0 评论 -
PAT甲级记录
这个适用于我自己总结自己那些题做的不好,不会,便于考前或平时的复习和查阅; 1002 1009忘记系数在过程中为0的情况 1012 23分,排名细节处理不好 1024 回文数处理不好,字符串理解不透彻 1037 two point 思想 1038 字符串比较 1056 模拟,队列,比赛团体人数的判断结束技巧,细节处理 1060 模拟,科学计数法, ========================...原创 2020-02-02 20:59:14 · 109 阅读 · 0 评论 -
1059 Prime Factors
Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p 1 k 1 ×p 2 k 2 ×⋯×p m k m . Input Specification:...原创 2020-02-02 20:44:16 · 94 阅读 · 0 评论 -
1022 Digital Library
A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number a...原创 2020-01-29 22:32:11 · 78 阅读 · 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...原创 2020-01-29 17:13:54 · 73 阅读 · 0 评论 -
1001 A+B Format && 1002 A+B for Polynomials
1001 A+B Format 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...原创 2020-01-27 21:42:40 · 116 阅读 · 0 评论 -
1021 Deepest Root
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 ...原创 2020-01-25 13:49:28 · 111 阅读 · 3 评论 -
1147 Heaps
In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...原创 2020-01-23 23:06:19 · 67 阅读 · 0 评论 -
1098 Insertion or Heap Sort
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, ...原创 2020-01-23 16:27:49 · 80 阅读 · 0 评论 -
1114 Family Property
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...原创 2020-01-20 21:57:44 · 710 阅读 · 0 评论 -
1051 Pop Sequence
Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the...原创 2019-11-21 21:52:50 · 98 阅读 · 0 评论 -
1097 Deduplication on a Linked List
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a...原创 2019-11-21 10:39:18 · 89 阅读 · 0 评论 -
1074 Reversing Linked List
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=4,...原创 2019-11-20 20:41:22 · 71 阅读 · 0 评论 -
1143 Lowest Common Ancestor
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. A binary search tree (BST) is recursively defined as a binary tree which has t...原创 2019-11-19 20:30:01 · 113 阅读 · 0 评论 -
1115 Counting Nodes in a 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 or equal to the node’s key. Th...原创 2019-11-12 18:56:23 · 103 阅读 · 0 评论 -
1127 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...原创 2019-11-12 17:28:42 · 104 阅读 · 0 评论 -
1130 Infix Expression
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 file contains...原创 2019-11-11 21:25:08 · 70 阅读 · 0 评论 -
1123 Is It a Complete AVL Tree
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 is...原创 2019-11-11 20:13:56 · 70 阅读 · 0 评论 -
1110 Complete Binary Tree
Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (≤20) whic...原创 2019-11-11 18:06:54 · 76 阅读 · 0 评论 -
1066 Root of AVL Tree
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 is...原创 2019-11-10 14:58:39 · 65 阅读 · 0 评论 -
1099 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 subt...原创 2019-11-09 19:18:32 · 59 阅读 · 0 评论 -
1064 Complete 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 subt...原创 2019-11-07 18:37:27 · 110 阅读 · 1 评论 -
1043 Is It 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 subt...原创 2019-11-07 17:38:47 · 63 阅读 · 0 评论 -
1053 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 fro...原创 2019-11-07 10:05:22 · 69 阅读 · 0 评论 -
1004 Counting Leaves
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-11-03 18:20:43 · 68 阅读 · 0 评论 -
1106 Lowest Price in Supply Chain
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-11-03 17:57:48 · 116 阅读 · 1 评论 -
1094 The Largest Generation
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-11-03 16:51:54 · 60 阅读 · 0 评论 -
1079 Total Sales of Supply Chain
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-11-03 15:56:15 · 75 阅读 · 0 评论 -
1090 Highest Price in Supply Chain
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-11-03 15:22:40 · 51 阅读 · 0 评论 -
1102 Invert a Binary Tree
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 turn to pro...原创 2019-11-03 13:03:46 · 58 阅读 · 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-10-31 18:28:34 · 56 阅读 · 0 评论 -
1020 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...原创 2019-10-31 17:33:18 · 53 阅读 · 0 评论 -
1107 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 thei...原创 2019-10-29 19:43:48 · 84 阅读 · 0 评论 -
1021 Deepest Root
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 ...原创 2019-10-24 17:57:59 · 110 阅读 · 0 评论 -
1013 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...原创 2019-10-24 16:19:14 · 88 阅读 · 0 评论 -
1076 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 ...原创 2019-10-22 18:30:08 · 55 阅读 · 0 评论 -
1034 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...原创 2019-10-22 17:07:21 · 99 阅读 · 0 评论