PTA + PAT
文章平均质量分 73
楚江枫
不忘初心,方得始终
展开
-
【PTA 5-1 N个数求和 (20分)】+ gcd
5-1 N个数求和 (20分) 本题的要求很简单,就是求N个数字的和。麻烦的是,这些数字是以有理数分子/分母的形式给出的,你输出的和也必须是有理数的形式。输入格式:输入第一行给出一个正整数N(\le≤100)。随后一行按格式a1/b1 a2/b2 …给出N个有理数。题目保证所有分子和分母都在长整型范围内。另外,负数的符号一定出现在分子前面。输出格式:输出上述数字和的最简形式 —— 即将结果写成原创 2017-03-23 18:28:30 · 1867 阅读 · 0 评论 -
【PAT 1001 Public Bike Management (30)】+ dfs + dijkstra
题目描述 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 ...原创 2017-07-26 20:59:33 · 432 阅读 · 0 评论 -
【PTA 5-10 树的遍历 (25分)】+ 二叉树
5-10 树的遍历 (25分) 给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列。这里假设键值都是互不相等的正整数。 输入格式:输入第一行给出一个正整数NN(\le 30≤30),是二叉树中结点的个数。第二行给出其后序遍历序列。第三行给出其中序遍历序列。数字间以空格分隔。 输出格式:在一行中输出该树的层序遍历的序列。数字间以1个空格分隔,行首尾不得有多余空格。 输入样例:7原创 2017-03-23 21:26:57 · 3153 阅读 · 0 评论 -
【PTA 5-11 玩转二叉树 (25分)】+ 二叉树
5-11 玩转二叉树 (25分) 给定一棵二叉树的中序遍历和前序遍历,请你先将树做个镜面反转,再输出反转后的层序遍历的序列。所谓镜面反转,是指将所有非叶结点的左右孩子对换。这里假设键值都是互不相等的正整数。 输入格式:输入第一行给出一个正整数N(\le≤30),是二叉树中结点的个数。第二行给出其中序遍历序列。第三行给出其前序遍历序列。数字间以空格分隔。 输出格式:在一行中输出该树反转后的层原创 2017-03-23 21:48:46 · 1566 阅读 · 0 评论 -
【PAT 1002 All Roads Lead to Rome】+ dfs + dijkstra
All Roads Lead to Rome (30) 时间限制 1000 ms 内存限制 65536 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 Indeed there are many different tourist routes from our city to Rome. You are supposed to find your c原创 2017-07-28 17:35:33 · 748 阅读 · 0 评论 -
【PAT 1004 Acute Stroke (30)】& dfs
题目描述 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 i原创 2017-09-05 17:14:35 · 258 阅读 · 0 评论 -
【PAT 1005 The Largest Generation (25)】& 树 & dfs
题目描述 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.输入原创 2017-09-05 16:22:18 · 365 阅读 · 0 评论 -
【PAT 1003 Highest Price in Supply Chain (25)】 & dfs
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 ch原创 2017-09-05 15:41:39 · 296 阅读 · 0 评论 -
【PAT 1006 Cars on Campus (30)】
题目描述 Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available原创 2017-09-14 17:43:42 · 323 阅读 · 0 评论 -
【1008 Deduplication on a Linked List (25)】+ 链表
题目描述 Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the valu原创 2017-09-15 08:57:52 · 319 阅读 · 0 评论 -
【PAT 1135. Is It A Red-Black Tree (30)】& 二叉树
Is It A Red-Black Tree (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue There is a kind of balanced binary search tree named red-black tree in the data structure. It h原创 2017-09-19 17:05:50 · 2942 阅读 · 0 评论 -
【 PAT 1007 Consecutive Factors (20)】
题目描述 Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3*5*6*7, where 5, 6, and 7 are the three consecutive numbers. Now原创 2017-09-13 08:11:42 · 315 阅读 · 0 评论