题目链接:http://poj.org/problem?id=2288
题意:每个点有一个权值Vi,找一条哈密顿路径,路径的权值来自三条:1 路径上的Vi之和 2 所有相邻点对ij的Vi*Vj之和 3 相邻连续三点i,j,k(并且三点要构成三角形)Vi*Vj*Vk之和。
解法:dp[st][i][j]表示从j走到i并且剩下集合st没有走的最大权值。关于路径书,在转移的时候顺便计算即可;...
分类:
其他好文 时间:
2014-06-28 09:07:03
阅读次数:
213
题目:
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the ta...
分类:
其他好文 时间:
2014-06-28 08:17:11
阅读次数:
305
Problem :It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and ...
分类:
其他好文 时间:
2014-06-28 08:13:17
阅读次数:
249
Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root ...
分类:
其他好文 时间:
2014-06-27 23:13:24
阅读次数:
218
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.
分类:
其他好文 时间:
2014-06-27 12:11:50
阅读次数:
337
题目:把n个骰子扔在地上,所有骰子朝上一面的点数之和为s,输入n,打印出s的所有可能的值出现的概率int g_maxValue = 6; // ====================方法一====================void Probability(int number, int* p...
分类:
其他好文 时间:
2014-06-27 11:57:12
阅读次数:
221
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
分类:
其他好文 时间:
2014-06-27 11:43:25
阅读次数:
173
Now, instead outputting board configurations, return the total number of distinct solutions.
分类:
其他好文 时间:
2014-06-27 11:40:13
阅读次数:
277
Given a binary tree containing digits from 0-9 only, each root-to-leaf
path could represent a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find the tota...
分类:
其他好文 时间:
2014-06-27 09:53:29
阅读次数:
208
题目链接:http://acdream.info/problem?pid=1108
题意:n个数的数列,m次查询某个区间出现次数第k多的数出现的次数。n,m
解法:这个因为是离线的所以可以先统一处理,然后再输出。可以维护一个left和right指针,pre,pre[i]表示此时区间内出现次数大于等于i的数的种类。为了减少复杂度,关键是left和right的移动方式,即查询区间如何排...
分类:
其他好文 时间:
2014-06-27 09:38:07
阅读次数:
255