04 2020 档案
摘要:组合c(n,m)的三种计算方法 普通、杨辉打表、质因数分解
阅读全文
摘要:线段树的相关知识,分为求区间最值与求区间和两个版本,分别讲解线段树的单点更新、区间查询、区间更新、区间查询。
阅读全文
摘要:动态规划的基本思想 如果各个子问题不是独立的,不同的子问题的个数只是多项式量级,如果我们能够保存已经解决的子问题的答案,而在需要的时候再找出已求得的答案,这样就可以避免大量的重复计算。由此而来的基本思路是,用一个表记录所有已解决的子问题的答案,不管该问题以后是否被用到,只要它被计算过,就将其结果填入
阅读全文
摘要:题目 有n种物品和一个容积为V的背包,第i种物品有amount[i]个,体积cost[i]和价值valum[i],问如何选取物品使得放入背包的物品价值之和最大。 优化 amount[i]==1时,当01背包处理。 amount[i]≥1时,采用二进制拆分,从而转换成01背包求解,具体如下: 在上面的
阅读全文
摘要:有N种物品和一个容量为V的背包。第i种物品最多有p[i]件可用,每件费用是w[i],价值是v[i]v[i]v[i]。求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大。 具体转换为01背包的策略: 二进制拆分 将第i种物品分成若干件物品,其中 例如意见物品的p【i】为13,则
阅读全文
摘要:1.题目A reversible prime in any number system is a prime whose "reverse" in that number system is also a pri...
阅读全文
摘要:1.题目It is vitally important to have all the cities connected by highways in a war. If a city is occupied b...
阅读全文
摘要:1.题目Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answ...
阅读全文
摘要:1.题目A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members ...
阅读全文
摘要:参考https://blog.csdn.net/zhang__shuang_/article/details/86578800例题题目描述: 求任意两个不同进制非负整数的转换(2进制~16进制),所给整数在lon...
阅读全文
摘要:1.题目People often have a preference among synonyms of the same word. For example, some may prefer "the poli...
阅读全文
摘要:1.题目Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of...
阅读全文
摘要:1.题目For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in n...
阅读全文
摘要:1.题目Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elemen...
阅读全文
摘要:1.题目Scientific notation is the way that scientists easily handle very large numbers or very small numbers....
阅读全文
摘要:1.题目A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involv...
阅读全文
摘要:1.题目The task of this problem is simple: insert a sequence of distinct positive integers into a hash table,...
阅读全文
摘要:1.题目The Japanese language is notorious for its sentence ending particles. Personal preference of such part...
阅读全文
摘要:1.题目Given a list of N student records with name, ID and grade. You are supposed to sort the records with r...
阅读全文
摘要:1.题目Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.In...
阅读全文
摘要:1.题目Indeed there are many different tourist routes from our city to Rome. You are supposed to find your cl...
阅读全文
摘要:1.题目An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, ...
阅读全文
摘要:1.题目Given a sequence of positive integers and another positive integer p. The sequence is said to be a per...
阅读全文
摘要:1.题目On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters c...
阅读全文
摘要:1.题目A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involv...
阅读全文
摘要:1.题目According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growi...
阅读全文
摘要:1.题目For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their...
阅读全文
摘要:理解 我们可以把N个数两两建立无向边(即任意两个结点之间都有边,也就是一个N个结点的完全图),然后对每个点作为起点,分别做一次深度优先遍历,当所有点都已经标记时输出当前的遍历路径,就是其中一个排列,这里需要注意,回溯的时候需要将原先标记的点的标记取消,否则只能输出一个排列。如果要按照字典序,则需要在
阅读全文
摘要:1.题目A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belon...
阅读全文
摘要:1.题目The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and t...
阅读全文
摘要:1.题目Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy s...
阅读全文
摘要:1.题目A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:...
阅读全文
摘要:1.题目According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growi...
阅读全文
摘要:1.题目Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated a...
阅读全文
摘要:1.题目Among all the factors of a positive integer N, there may exist several consecutive numbers. For exampl...
阅读全文
摘要:1.题目The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Hom...
阅读全文
摘要:1.题目There is a classical process named partition in the famous quick sort algorithm. In this process we ty...
阅读全文
摘要:1.题目People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars. The numbers 1 ...
阅读全文
摘要:1.题目When register on a social network, you are always asked to specify your hobbies in order to find some ...
阅读全文
摘要:1.题目This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing...
阅读全文
摘要:1.题目Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For exampl...
阅读全文
摘要:1.题目Input our current position and a destination, an online map can recommend several paths. Now your job ...
阅读全文
摘要:1.题目Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input ...
阅读全文
摘要:1.题目Formation is very important when taking a group photo. Given the rules of forming K rows with N people...
阅读全文
摘要:1.题目The basic task is simple: given N real numbers, you are supposed to calculate their average. But what ...
阅读全文
摘要:1.题目This time, you are supposed to help us collect the data for family-owned property. Given each person's...
阅读全文
摘要:1.题目A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:...
阅读全文
摘要:1.题目Given a set of N (>1) positive integers, you are supposed to partition them into two disjoint sets A1...
阅读全文
摘要:1.题目On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the charac...
阅读全文
摘要:1.题目An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtr...
阅读全文
摘要:1.题目Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in t...
阅读全文
摘要:1.题目British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he ...
阅读全文
摘要:1.题目"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Techn...
阅读全文
摘要:1.题目The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a c...
阅读全文
摘要:1.题目"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find ...
阅读全文
摘要:1.题目Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is th...
阅读全文
摘要:1.题目Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be...
阅读全文