![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pat-a
wangfy_
这个作者很懒,什么都没留下…
展开
-
1141 PAT Ranking of Institutions (25)
(待)原创 2018-05-14 22:35:06 · 161 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25)
Maximum Subsequence Sum.Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1 <= i <= j <= K. The Maximum Subsequence...原创 2018-06-03 21:32:53 · 176 阅读 · 0 评论 -
1001 A+B Format (20)
#include <cstdio>#include <cmath>using namespace std;const int MAXN = 10010;int main() { int long long a, b, c; scanf("%lld%lld",&a,&b); c = a + b; if(c < 0) { printf(...原创 2018-05-22 12:24:38 · 160 阅读 · 0 评论 -
pat-a
1001 A+B Format (20) 1002 A+B for Polynomials (25) 1003 Emergency (25) 1004 Counting Leaves (30) 1005 Spell It Right (20) 1006 Sign In and Sign Out (25) 1007 Maximu...原创 2018-05-21 22:28:59 · 614 阅读 · 0 评论 -
PATA 1090
Highest 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.Starting fr...原创 2018-03-29 20:39:48 · 197 阅读 · 0 评论 -
PATA 1079
Total Sales(所有零售商总共卖多少钱) of Supply Chain (25)A supply chain(供应链) is a network of :retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to cus...原创 2018-03-29 20:38:34 · 229 阅读 · 0 评论 -
PATA 170304 D
//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 simp...原创 2018-03-29 20:15:48 · 119 阅读 · 0 评论 -
1020 Tree Traversals (25)
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 ...原创 2018-03-29 20:12:34 · 179 阅读 · 0 评论 -
1086 Tree Traversals Again (25)
Tree Traversals Again (25)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...原创 2018-03-29 20:11:13 · 154 阅读 · 0 评论 -
1002 A+B for Polynomials (25) -
A+B for Polynomials(多项式).This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains...原创 2018-05-23 19:19:51 · 140 阅读 · 0 评论 -
1008 Elevator (20)
#include <cstdio>int main() { int N, s = 0, c = 0; scanf("%d",&N); for(int i=0; i<N; i++) { int t; scanf("%d",&t); if(c > t) s += 4 * (c - t); if(c < t) s += 6 * (t ...原创 2018-06-04 23:19:52 · 143 阅读 · 0 评论 -
1021 Deepest Root (25)
(待)原创 2018-06-27 22:34:45 · 432 阅读 · 1 评论 -
ANOJ 1008 进击的二叉查找树 (判断两棵BST是否完全一致)
Test: 判断两棵BST是否完全一致【Thinking】1. 分别建两棵BST,然后把它们遍历到数组中,判断两个数组是否一致2. 直接建两棵CBST,然后直接比较数组,省去了1法中的遍历的过程3. 建一棵BST,判别其他序列是否与该树一致4. 不建BST...?-------- 代码1 建一棵BST,判别其他序列是否与该树一致 --------#include <cst...原创 2018-03-31 08:34:46 · 244 阅读 · 0 评论 -
1013 Battle Over Cities (25)
//code1 DFS数出连通块数 -------------------------------#include <cstdio>#include <vector>#include <cstring>using namespace std;const int MAXN = 1010;vector<int> G[MAXN];bool v...原创 2018-06-25 00:26:36 · 141 阅读 · 0 评论 -
1006 Sign In and Sign Out (25)
Sign In and Sign OutAt the beginning of every day, the first person who signs in the computer room will unlock(开锁) the door, and the last one who signs out will lock the door. Given the records of ...原创 2018-06-01 22:02:58 · 172 阅读 · 0 评论 -
1005 Spell It Right (20)
Spell It Right.Given a non-negative(非负) integer N, your task(任务) is to compute(计算) the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input fil...原创 2018-06-01 10:20:13 · 156 阅读 · 0 评论 -
1004 Counting Leaves (30)
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 ...原创 2018-06-01 04:27:04 · 328 阅读 · 0 评论 -
1009 Product of Polynomials (25)
Product of Polynomials(多项式的积).This time, you are supposed to find A*B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, an...原创 2018-06-06 10:31:33 · 148 阅读 · 0 评论 -
1003 Emergency (25)
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 rescu...原创 2018-05-29 19:06:09 · 322 阅读 · 0 评论 -
PATA 1102
Invert(反) a Binary Tree (25)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...原创 2018-03-29 20:09:27 · 142 阅读 · 0 评论 -
ANOJ 1005 还原二叉树
// 层序中序 求先/后序// ANOJ-180311-D#include <cstdio>const int MAXN = 10010;int n, layer[MAXN], in[MAXN];struct node { int data; node* l; node* r; };node* create(int *layer, int *in, int t) ...原创 2018-03-29 20:04:19 · 197 阅读 · 0 评论 -
PATA 1094
The Largest Generation (25)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 w...原创 2018-03-29 20:40:19 · 169 阅读 · 0 评论 -
PATA 1030
Travel Plan (30)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...原创 2018-03-31 08:34:54 · 143 阅读 · 0 评论 -
PATA 1018
以下代码全都不对,则良机重写!1018. Public Bike Management (30)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at a...原创 2018-03-31 08:35:04 · 233 阅读 · 0 评论 -
PATA 1070
Mooncake (25)Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region...原创 2018-04-03 18:22:19 · 148 阅读 · 0 评论 -
PATA 1037
Magic Coupon (25)The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the va...原创 2018-04-03 18:22:24 · 174 阅读 · 0 评论 -
PATA 1067
Sort with Swap(0,*) (25)Given any permutation of the numbers {0, 1, 2,..., N-1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? ...原创 2018-04-03 18:22:28 · 190 阅读 · 0 评论 -
PATA 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.Starting fro...原创 2018-03-31 08:34:04 · 140 阅读 · 0 评论 -
ANOJ 180315 C
//https://logn.me/problem/1024//10 8//2 6 1 2 0 9 5 0 3 6//0 1//0 2//0 3//1 4//1 5//3 6//7 8//8 9//2//775 36#include <cstdio>#include <vector>using namespace std;const ...原创 2018-03-31 08:34:26 · 120 阅读 · 0 评论 -
1034 Head of a Gang (30)
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 rel...原创 2018-02-21 13:12:45 · 158 阅读 · 0 评论 -
1076 Forwards on Weibo (30)
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 follow...原创 2018-02-21 13:13:23 · 180 阅读 · 0 评论 -
1099 Build A Binary Search Tree (30)
Build A Binary Search Tree (30)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...原创 2018-03-31 08:34:42 · 155 阅读 · 0 评论 -
1064 Complete Binary Search Tree (30)
Complete Binary Search Tree (30)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 key...原创 2018-03-31 08:34:38 · 374 阅读 · 0 评论 -
1043 Is It a Binary Search Tree (25)
Is It a Binary Search Tree (25)二叉搜索树的定义: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 ke...原创 2018-03-31 08:34:34 · 194 阅读 · 0 评论 -
1140 Look-and-say Sequence(20)
//将每个不同的字符存入,初始字符后面的个数为1,//之后下一个时判断是否去前一个字符相同,相同则个数++;//不同的将新字符存入,并且个数初始为1。 #include <cstdio>#include <cstring>int main() { char str[50][10000] = {}; int D, N; scanf("%d %d",&...原创 2018-07-24 23:19:16 · 322 阅读 · 0 评论