pat
王重阳道长
这个作者很懒,什么都没留下…
展开
-
PAT甲级1138 Postorder Traversal (25 分)
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...原创 2019-11-18 21:23:11 · 164 阅读 · 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 of the cor...原创 2019-11-18 17:29:29 · 146 阅读 · 0 评论 -
1143 Lowest Common Ancestor (30 分)
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-17 13:49:51 · 311 阅读 · 0 评论 -
PAT甲级1088 Rational Arithmetic (20 分)
For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test cas...原创 2019-11-15 16:10:31 · 144 阅读 · 0 评论 -
甲级1106 Lowest Price in Supply Chain (25 分)
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.Startin...原创 2019-11-13 23:18:28 · 119 阅读 · 0 评论 -
甲级1105 Spiral Matrix (25 分)
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 matrix is filled in from the first element at the upper...原创 2019-11-13 20:40:48 · 257 阅读 · 0 评论 -
1102 Invert a Binary Tree (25 分)
题意:给你一棵树,让你bfs一遍,然后中序遍历一遍。坑点:Invert这个单词的含义是反转的意思,也就是左右子树要互换。建树完了,跑一边遍历序列就好了。#include<bits/stdc++.h>#pragma GCC optimize(2)#define MAXN 15#define maxnode 1000005#define sigma_size 26#defin...原创 2019-11-13 17:27:54 · 103 阅读 · 0 评论 -
1053 Path of Equal Weight (30 分)
题意:给定一棵树,要求你遍历,输出路径和为要求值得路径。看大家写的那么 累,我来写一篇。思路:难点就是遍历,输出顺序要求是非降序,所以我们在建图的时候需要预处理,怎么办呢?将价值大的排在前面,所以我们直接建完图之后排序一遍就好了。具体看代码;#include<bits/stdc++.h>#pragma GCC optimize(2)#define MAXN 1...原创 2019-11-12 20:55:32 · 63 阅读 · 0 评论 -
PAT甲级--1144 The Missing Number (20 分)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line gives...原创 2019-08-14 12:57:52 · 82 阅读 · 0 评论 -
PAT--甲级 1101 Quick Sort (25 分)
There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its le...原创 2019-08-14 10:20:03 · 77 阅读 · 0 评论