这道题的题意其实有点略晦涩,定义f(a,b)为minimum of verticesnoton the path between vertices a and b. 其实它加一个minimum index of vertices应该会好理解一点吧。看了一下题解,还有程序,才理清思路。首先比较直接的是...
分类:
其他好文 时间:
2014-08-06 14:27:11
阅读次数:
270
DescriptionUnidirectional TSPBackgroundProblems that require minimum paths through some domain appear in many different areas of computer science. For...
分类:
其他好文 时间:
2014-08-06 14:16:41
阅读次数:
336
HDU 1394 Minimum Inversion Number(线段树求最小逆序数对)
ACM
题目地址:HDU 1394 Minimum Inversion Number
题意:
给一个序列由[1,N]构成,可以通过旋转把第一个移动到最后一个。
问旋转后最小的逆序数对。
分析:
注意,序列是由[1,N]构成的,我们模拟下旋转,总的逆序数对会有规律的变化。 ...
分类:
其他好文 时间:
2014-08-06 01:56:10
阅读次数:
162
Problem Description
bobo has a sequence a1,a2,…,an. He is allowed to swap two
adjacent numbers for no more than k times.
Find the minimum number of inversions after his swaps.
Note: The number...
分类:
其他好文 时间:
2014-08-05 22:44:03
阅读次数:
248
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8">
<metaname="viewport"content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=yes">
<title>TOUCH</title>
<styletype="text/css">
*{
margin:..
分类:
其他好文 时间:
2014-08-05 14:26:11
阅读次数:
275
题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partition....
分类:
编程语言 时间:
2014-08-05 13:32:29
阅读次数:
252
平方剩余和欧拉准则
若p=2或p=4*k+1 则p可以表成两平方数的和的形式 (欧拉和费马已证明,并且有求的方法) 所以答案是p
若p=4*k+3 设a^2=n(mod p) (n!=0) 可以证明不存在b,b^2=p-n(mod p) 即若n是p的平方剩余 则p-n不是p的平方剩余
证明:因为a^2=n(mod p) 所以由欧拉准则 得n^((p-1)/2)=1(mod p)
若b^2...
分类:
其他好文 时间:
2014-08-05 11:14:26
阅读次数:
207
最小生成树
给定一无向带权图,顶点数是n,要使图连通只需n-1条边,若这n-1条边的权值和最小,则称有这n个顶点和n-1条边构成了图的最小生成树(minimum-cost spanning tree)。
Prim算法
Prim算法是解决最小生成树的常用算法。它采取贪心策略,从指定的顶点开始寻找最小权值的邻接点。图G=,初始时S={V0},把与V0相邻接,且边的权值最小的顶点加入到S。不断地把S中的顶点与V-S中顶点的最小权值边加入,直到所有顶点都已加入到S中。...
分类:
其他好文 时间:
2014-08-05 00:39:08
阅读次数:
313
这题关键注意:T可能有重复,所以得统计次数,我之前理解错了,后来参考别人代码才知道的。思路就是双指针+字符hash,具体见注释 1 class Solution { 2 public: 3 string minWindow(string S, string T) { 4 ...
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...
分类:
其他好文 时间:
2014-08-03 22:59:56
阅读次数:
259