爆搜解法: 一开始老是超时,用的手动搜索全排列,结果看一下题解,结果全部用的是next_permutation这个函数,就是用来做全排列的,改了一下,竟然过了,不得不说库函数还是蛮强的,推测一下它应该用的应该不是深搜实现的,不然应该不会这么快。(好想知道它用的什么算法呀!) 这个函数在algorit ...
分类:
其他好文 时间:
2018-05-28 21:18:49
阅读次数:
157
1038 Recover the Smallest Number (30)(30 分) Given a collection of number segments, you are supposed to recover the smallest number from them. For exam ...
分类:
其他好文 时间:
2018-05-27 16:47:48
阅读次数:
167
题目链接: https://www.luogu.org/problemnew/show/UVA11536 题目大意: 给定一个$N,M,K$,构造这样的数列: $x[1]=1,x[2]=2,x[3]=3$ $x[i]=(x[i 1]+x[i 2]+x[i 3])\mod M+1(N =i =4)$ ...
分类:
其他好文 时间:
2018-05-26 23:26:46
阅读次数:
395
方法一: 一种直观的解是,先对第一个字串排序,然后逐个字符在第二个字串中搜索,把搜索不到的字符输出,就是所要的结果。 然而,算法库中有一个集合差运算set_difference,而且要求两个集合容器是已经排好序的。乍一看,好像是针对集合差运算来的。 方法二: 然而注意到,对两个集合分别排序的代价是大 ...
分类:
编程语言 时间:
2018-05-26 11:47:06
阅读次数:
166
原题网址:https://www.lintcode.com/problem/maximum-subarray-difference/description 描述 给定一个整数数组,找出两个不重叠的子数组A和B,使两个子数组和的差的绝对值|SUM(A) - SUM(B)|最大。 返回这个最大的差值。 ...
分类:
编程语言 时间:
2018-05-25 00:24:39
阅读次数:
221
传送门 题目 You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obta ...
分类:
其他好文 时间:
2018-05-21 19:49:35
阅读次数:
167
那么这道题给的提示是让我们用BST的性质来解题,最重要的性质是就是左<根<右,那么如果用中序遍历所有的节点就会得到一个有序数组。所以解题的关键还是中序遍历啊。 ...
分类:
其他好文 时间:
2018-05-21 14:38:58
阅读次数:
176
Smallest Number (medium): 求1-N的LCM,多组数据。 Divisors of factorial (hard) 求N的阶乘的因子个数。 ...
分类:
其他好文 时间:
2018-05-21 14:35:03
阅读次数:
122
41. First Missing Positive Given an unsorted integer array, find the smallest missing positive integer. Example 1: Example 2: Example 3: Note: Your al ...
分类:
其他好文 时间:
2018-05-20 15:19:29
阅读次数:
180