![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT
sanctuary_wu
这个作者很懒,什么都没留下…
展开
-
PAT 甲级 1045 Favorite Color Stripe
Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts...原创 2020-03-09 16:10:48 · 144 阅读 · 0 评论 -
PAT 甲级 1087 All Roads Lead to Rome
Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each in...原创 2020-03-08 13:15:51 · 134 阅读 · 0 评论 -
PAT 甲级 1072 Gas Station
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou...原创 2020-03-07 21:01:40 · 119 阅读 · 0 评论 -
PAT 甲级 1018 Public Bike Management(Dijkstra+DFS)
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 any station and return it to any other stations in the ...原创 2020-03-06 14:29:19 · 156 阅读 · 0 评论 -
蓝桥杯 2013 I题 剪格子
如图p1所示,3 x 3 的格子中填写了一些整数。我们沿着图中的红色线剪开,得到两个部分,每个部分的数字和都是60。本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是否可以分割为两个部分,使得这两个区域的数字和相等。如果存在多种解答,请输出包含左上角格子的那个区域包含的格子的最小数目。如果无法分割,则输出 0输入:程序先读入两个整数 m n 用空格分割 (m,n<...原创 2020-03-05 11:45:05 · 132 阅读 · 0 评论 -
PAT 甲级 1030 Travel Plan(Dijkstra 以及 Dijkstra+DFS)
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 the shortest path b...原创 2020-03-03 15:18:30 · 124 阅读 · 0 评论 -
PAT 甲级 1003 Emergency(Dijkstra的运用)
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 rescue teams in each city and the l...原创 2020-03-02 20:52:35 · 162 阅读 · 0 评论 -
PAT 甲级 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-03-01 15:57:16 · 92 阅读 · 0 评论 -
PAT 甲级 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...原创 2020-02-27 16:13:52 · 108 阅读 · 0 评论 -
PAT 甲级 1099 Build A Binary Search Tree(30分)
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...原创 2020-02-26 21:18:14 · 75 阅读 · 0 评论 -
PAT 甲级 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...原创 2020-02-26 19:46:56 · 105 阅读 · 0 评论 -
PAT 甲级 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 sub...原创 2020-02-26 17:58:17 · 106 阅读 · 0 评论 -
PAT 甲级 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...原创 2020-02-25 17:27:32 · 80 阅读 · 0 评论 -
PAT 甲级 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...原创 2020-02-25 15:33:49 · 105 阅读 · 0 评论 -
PAT 甲级 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 from one root supplier, everyone on the ...原创 2020-02-25 13:48:00 · 98 阅读 · 0 评论 -
PAT 甲级 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 customer.Starting from one root supplier, everyone on the...原创 2020-02-25 11:52:48 · 160 阅读 · 0 评论 -
PAT 甲级 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 fr...原创 2020-02-25 10:32:23 · 81 阅读 · 0 评论 -
PAT 甲级 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 p...原创 2020-02-24 11:24:05 · 141 阅读 · 0 评论 -
PAT 甲级 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...原创 2020-02-23 20:18:49 · 86 阅读 · 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...原创 2020-02-23 15:51:03 · 71 阅读 · 0 评论 -
PAT 甲级 1091 Acute Stroke (BFS)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to c...原创 2020-02-22 12:33:37 · 108 阅读 · 0 评论 -
PAT 甲级 1103 Integer Factorization(DFS)
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-20 21:01:06 · 112 阅读 · 0 评论 -
PAT 乙级1025/甲级 1074 反转链表
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,...原创 2020-02-19 16:21:52 · 83 阅读 · 0 评论 -
PAT 甲级 1032 Sharing (25分)测试点三坑
To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...原创 2020-02-18 20:54:00 · 1495 阅读 · 1 评论 -
PAT 甲级 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...原创 2020-02-16 21:36:06 · 116 阅读 · 0 评论 -
PAT-乙级1045-快速排序-甲级1101-Quick-Sort-25分
著名的快速排序算法里有一个经典的划分过程:我们通常采用某种方法取一个元素作为主元,通过交换,把比主元小的元素放到它的左边,比主元大的元素放到它的右边。 给定划分后的 N 个互不相同的正整数的排列,请问有多少个元素可能是划分前选取的主元?例如给定 N=5N = 5N=5, 排列是1、3、2、4、5。则:1 的左边没有元素,右边的元素都比它大,所以它可能是主元;尽管 3 的左边元素都比它小,但其...原创 2020-02-11 13:36:23 · 97 阅读 · 0 评论 -
PAT 甲级1089 Insert or Merge (25分)
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, finds the location it be...原创 2020-02-10 16:54:02 · 113 阅读 · 0 评论 -
PAT 乙级 1030 完美数列(二分查找 及 upper_bound()函数的使用)
给定一个正整数数列,和正整数 p,设这个数列中的最大值是 M,最小值是 m,如果 M≤mp,则称这个数列是完美数列。现在给定参数 p 和一些正整数,请你从中选择尽可能多的数构成一个完美数列。输入格式:输入第一行给出两个正整数 N 和 p,其中 N(≤105)是输入的正整数的个数,p(≤109)是给定的参数。第二行给出 N 个正整数,每个数不超过109。输出格式:在一行中输出最多可以选择多...原创 2020-02-08 13:13:23 · 129 阅读 · 0 评论 -
PAT 甲级 1038 Recover the Smallest Number
Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229...原创 2020-02-07 19:57:35 · 141 阅读 · 0 评论 -
PAT甲级1033 To Fill or Not to Fill 贪心算法的使用
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different ga...原创 2020-02-06 18:47:38 · 132 阅读 · 0 评论 -
PAT乙级 1005 继续(3n+1)猜想
卡拉兹(Callatz)猜想已经在1001中给出了描述。在这个题目里,情况稍微有些复杂。当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数。例如对 n=3 进行验证的时候,我们需要计算 3、5、8、4、2、1,则当我们对 n=5、8、4、2 进行验证的时候,就可以直接判定卡拉兹猜想的真伪,而不需要重复计算,因为这 4 个数已经在验证3的时候遇到过了,我们称 5、8、...原创 2020-02-05 10:39:52 · 178 阅读 · 0 评论 -
PAT甲级 1080 Graduate Admission
It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission...原创 2020-02-02 10:00:43 · 175 阅读 · 0 评论 -
PAT 甲级 1075 PAT Judge(第5个测试点解决方法)
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file cont...原创 2020-02-01 13:25:50 · 1232 阅读 · 13 评论 -
PAT甲级 1025 PAT Ranking
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists w...原创 2020-01-30 10:11:33 · 77 阅读 · 0 评论 -
PAT 乙级 1048 数字加密
题目:本题要求实现一种数字加密方法。首先固定一个加密用正整数 A,对任一正整数 B,将其每 1 位数字与 A 的对应位置上的数字进行以下运算:对奇数位,对应位的数字相加后对 13 取余——这里用 J 代表 10、Q 代表 11、K 代表 12;对偶数位,用 B 的数字减去 A 的数字,若结果为负数,则再加 10。这里令个位为第 1 位。输入格式:输入在一行中依次给出 A 和 B,均为不超过 ...原创 2020-01-29 09:22:51 · 146 阅读 · 0 评论