PAT A1001-A1004

A1002 : A+B for Polynomials (25 point(s))

The key to solving this problem is the condition given by the problem: the power of each polynomial is gradually reduced.

  1. You can find the larger terms of polynomials in turn for processing.

  2. You can also directly create an array with a capacity of 1000 and treat them as 1000 term polynomials.

The code of method 1 is as follows:

A1003 : Emergency (25 point(s))

The key to solving this problem is: the shortest path (Dijkstra), the number of shortest paths (the sum of the number of paths at the last node of all shortest paths), and the maximum number of ambulance personnel (the maximum number of ambulance personnel at the last node of all shortest paths + the number of ambulance personnel at this node)

  1. Adjacency matrix storage, Dijkstra processing

The code is as follows:

A1003 : Counting Leaves (30 point(s))

The key to solving this problem is to output the number of leaf nodes per layer.

Note: it is not processed when n is 0

  1. Static storage tree, BFS

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>