原创 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

原创 PAT甲級 1108. Finding Average (20)

The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complica

原创 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

原创 PAT甲級 1106. Lowest Price in Supply Chain (25)

A supply chain is a network of retailers(零售商), distributors(經銷商), and suppliers(供應商)-- everyone involved in moving a pr

原创 PAT甲級 1103. Integer Factorization (30)

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 ar

原创 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

原创 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

原创 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

原创 PAT甲級 1105. Spiral Matrix (25)

This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral

原创 PAT甲級 1111. Online Map (30)

Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend t

原创 pat甲級 1009. Product of Polynomials (25)

This time, you are supposed to find A*B where A and B are two polynomials.Input Specification:Each input file contains

原创 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 sequ

原创 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 al

原创 PAT甲級 1110. Complete Binary Tree (25)

Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one

原创 PAT甲級 1118 Birds in Forest (25)

Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture b