2017年7月9日

【转】什么是动态规划?动态规划的意义是什么

摘要: https://www.zhihu.com/question/23995189 徐凯强 Andy 永远好奇 赵劼 、 空明流转 等 1818 人赞同了该回答 动态规划中递推式的求解方法不是动态规划的本质。 我曾经作为省队成员参加过NOI,保送之后也给学校参加NOIP的同学多次讲过动态规划,我试着讲一 阅读全文

posted @ 2017-07-09 14:34 gravitykey 阅读(261) 评论(0) 推荐(0)

PTA 11-散列4 Hard Version (30分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/680 5-18 Hashing - Hard Version (30分) Given a hash table of size NN, we can define a hash funct 阅读全文

posted @ 2017-07-09 12:48 gravitykey 阅读(719) 评论(0) 推荐(0)

PTA 11-散列3 QQ帐户的申请与登陆 (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/723 5-15 QQ帐户的申请与登陆 (25分) 实现QQ新帐户申请和老帐户登陆的简化版功能。最大挑战是:据说现在的QQ号码已经有10位数了。 输入格式: 输入首先给出一个正整数NN(\l 阅读全文

posted @ 2017-07-09 12:41 gravitykey 阅读(1473) 评论(0) 推荐(0)

PTA 11-散列2 Hashing (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/679 5-17 Hashing (25分) The task of this problem is simple: insert a sequence of distinct positi 阅读全文

posted @ 2017-07-09 12:38 gravitykey 阅读(977) 评论(0) 推荐(0)

PTA 11-散列1 电话聊天狂人 (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/722 5-14 电话聊天狂人 (25分) 给定大量手机用户通话记录,找出其中通话次数最多的聊天狂人。 输入格式: 输入首先给出正整数NN(\le 10^5≤10​5​​),为通话记录条数。 阅读全文

posted @ 2017-07-09 12:36 gravitykey 阅读(830) 评论(0) 推荐(0)

PTA 10-排序6 Sort with Swap(0, i) (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/678 5-16 Sort with Swap(0, i) (25分) Given any permutation of the numbers {0, 1, 2,..., N-1N−1}, 阅读全文

posted @ 2017-07-09 12:31 gravitykey 阅读(912) 评论(0) 推荐(0)

PTA 10-排序5 PAT Judge (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/677 5-15 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the 阅读全文

posted @ 2017-07-09 12:29 gravitykey 阅读(1091) 评论(0) 推荐(0)

PTA 10-排序4 统计工龄 (20分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/721 5-13 统计工龄 (20分) 给定公司NN名员工的工龄,要求按工龄增序输出每个工龄段有多少员工。 输入格式: 输入首先给出正整数NN(\le 10^5≤10​5​​),即员工总人数 阅读全文

posted @ 2017-07-09 12:26 gravitykey 阅读(1440) 评论(0) 推荐(0)

PTA 09-排序3 Insertion or Heap Sort (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/676 5-14 Insertion or Heap Sort (25分) According to Wikipedia: Insertion sort iterates, consumin 阅读全文

posted @ 2017-07-09 12:25 gravitykey 阅读(638) 评论(0) 推荐(0)

PTA 09-排序2 Insert or Merge (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/675 5-13 Insert or Merge (25分) According to Wikipedia: Insertion sort iterates, consuming one i 阅读全文

posted @ 2017-07-09 12:23 gravitykey 阅读(516) 评论(0) 推荐(0)

PTA 09-排序1 排序 (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/720 5-12 排序 (25分) 给定NN个(长整型范围内的)整数,要求输出从小到大排序后的结果。 本题旨在测试各种不同的排序算法在各种数据情况下的表现。各组测试数据特点如下: 数据1:只 阅读全文

posted @ 2017-07-09 12:21 gravitykey 阅读(1778) 评论(0) 推荐(0)

PTA 08-图9 关键活动 (30分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/719 假定一个工程项目由一组子任务构成,子任务之间有的可以并行执行,有的必须在完成了其它一些子任务后才能执行。“任务调度”包括一组子任务、以及每个子任务可以执行所依赖的子任务集。 比如完成 阅读全文

posted @ 2017-07-09 12:14 gravitykey 阅读(2211) 评论(0) 推荐(0)

PTA 08-图8 How Long Does It Take (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/674 5-12 How Long Does It Take (25分) Given the relations of all the activities of a project, yo 阅读全文

posted @ 2017-07-09 12:12 gravitykey 阅读(689) 评论(0) 推荐(0)

PTA 08-图7 公路村村通 (30分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/718 5-10 公路村村通 (30分) 现有村落间道路的统计数据表中,列出了有可能建设成标准公路的若干条道路的成本,求使每个村落都有公路连通所需要的最低成本。 输入格式: 输入数据包括城镇 阅读全文

posted @ 2017-07-09 12:08 gravitykey 阅读(1777) 评论(0) 推荐(0)

PTA 07-图6 旅游规划 (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/717 5-9 旅游规划 (25分) 有了一张自驾旅游路线图,你会知道城市间的高速公路长度、以及该公路要收取的过路费。现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路 阅读全文

posted @ 2017-07-09 12:04 gravitykey 阅读(1106) 评论(0) 推荐(0)

PTA 07-图5 Saving James Bond - Hard Version (30分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/673 5-11 Saving James Bond - Hard Version (30分) This time let us consider the situation in the 阅读全文

posted @ 2017-07-09 12:01 gravitykey 阅读(521) 评论(0) 推荐(0)

PTA 07-图4 哈利·波特的考试 (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/716 5-8 哈利·波特的考试 (25分) 哈利·波特要考试了,他需要你的帮助。这门课学的是用魔咒将一种动物变成另一种动物的本事。例如将猫变成老鼠的魔咒是haha,将老鼠变成鱼的魔咒是he 阅读全文

posted @ 2017-07-09 11:59 gravitykey 阅读(1209) 评论(0) 推荐(0)

PTA 06-图3 六度空间 (30分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/715 5-7 六度空间 (30分) “六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的 阅读全文

posted @ 2017-07-09 11:56 gravitykey 阅读(701) 评论(0) 推荐(0)

PTA 06-图2 Saving James Bond - Easy Version (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/672 5-10 Saving James Bond - Easy Version (25分) This time let us consider the situation in the 阅读全文

posted @ 2017-07-09 11:46 gravitykey 阅读(404) 评论(0) 推荐(0)

PTA 06-图1 列出连通集 (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/714 5-6 列出连通集 (25分) 给定一个有NN个顶点和EE条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到N-1N−1编号。进行搜索时,假设我们总是从编号最小的 阅读全文

posted @ 2017-07-09 11:31 gravitykey 阅读(976) 评论(0) 推荐(0)

PTA 05-树9 Huffman Codes (30分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/671 5-9 Huffman Codes (30分) In 1953, David A. Huffman published his paper "A Method for the Con 阅读全文

posted @ 2017-07-09 11:25 gravitykey 阅读(738) 评论(0) 推荐(0)

PTA 05-树8 File Transfer (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/670 5-8 File Transfer (25分) We have a network of computers and a list of bi-directional connect 阅读全文

posted @ 2017-07-09 11:20 gravitykey 阅读(777) 评论(0) 推荐(0)

PTA 05-树7 堆中的路径 (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/713 5-5 堆中的路径 (25分) 将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任意给定的下标i,打印从H[i]到根结点的路径。 输入格式: 每组测试第1行包含2个正整数NN和 阅读全文

posted @ 2017-07-09 11:11 gravitykey 阅读(480) 评论(0) 推荐(0)

PTA 04-树6 Complete Binary Search Tree (30分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/669 5-7 Complete Binary Search Tree (30分) A Binary Search Tree (BST) is recursively defined as 阅读全文

posted @ 2017-07-09 10:00 gravitykey 阅读(388) 评论(0) 推荐(0)

PTA 04-树5 Root of AVL Tree (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/668 5-6 Root of AVL Tree (25分) An AVL tree is a self-balancing binary search tree. In an AVL tr 阅读全文

posted @ 2017-07-09 09:51 gravitykey 阅读(657) 评论(0) 推荐(0)

PTA 04-树4 是否同一棵二叉搜索树 (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/712 5-4 是否同一棵二叉搜索树 (25分) 给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和 阅读全文

posted @ 2017-07-09 09:42 gravitykey 阅读(503) 评论(0) 推荐(0)

PTA 03-树3 Tree Traversals Again (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/667 5-5 Tree Traversals Again (25分) An inorder binary tree traversal can be implemented in a no 阅读全文

posted @ 2017-07-09 09:30 gravitykey 阅读(393) 评论(0) 推荐(0)

PTA 03-树2 List Leaves (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/666 5-4 List Leaves (25分) Given a tree, you are supposed to list all the leaves in the order of 阅读全文

posted @ 2017-07-09 09:24 gravitykey 阅读(361) 评论(0) 推荐(0)

PTA 03-树1 树的同构 (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/711 5-3 树的同构 (25分) 给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结 阅读全文

posted @ 2017-07-09 09:17 gravitykey 阅读(877) 评论(0) 推荐(0)

PTA 02-线性结构4 Pop Sequence (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/665 5-3 Pop Sequence (25分) Given a stack which can keep MM numbers at most. Push NN numbers in 阅读全文

posted @ 2017-07-09 09:11 gravitykey 阅读(732) 评论(0) 推荐(0)

PTA 02-线性结构3 Reversing Linked List (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/664 5-2 Reversing Linked List (25分) Given a constant KK and a singly linked list LL, you are su 阅读全文

posted @ 2017-07-09 09:08 gravitykey 阅读(1322) 评论(0) 推荐(0)

PTA 02-线性结构2 一元多项式的乘法与加法运算 (20分)

摘要: 原题地址 https://pta.patest.cn/pta/test/15/exam/4/question/710 5-2 一元多项式的乘法与加法运算 (20分) 设计函数分别求两个一元多项式的乘积与和。 输入格式: 输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零 阅读全文

posted @ 2017-07-09 09:05 gravitykey 阅读(481) 评论(0) 推荐(0)

PTA 01-复杂度2 Maximum Subsequence Sum (25分)

摘要: 题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/663 5-1 Maximum Subsequence Sum (25分) Given a sequence of KK integers { N_1N​1​​, N_2N​2​​, ... 阅读全文

posted @ 2017-07-09 08:59 gravitykey 阅读(416) 评论(0) 推荐(0)

PTA 01-复杂度1 最大子列和问题 (20分)

摘要: 题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/709 5-1 最大子列和问题 (20分) 给定KK个整数组成的序列{ N_1N​1​​, N_2N​2​​, ..., N_KN​K​​ },“连续子列”被定义为{ N_iN​i​​, N 阅读全文

posted @ 2017-07-09 08:41 gravitykey 阅读(896) 评论(0) 推荐(0)

导航