题意为F束花插入V个瓶子里面,花要按编号递增顺序插,不同花插入不同的花瓶有不同的美观程度,要求最大的美观程度。一种f[i][j]表示第i束花插入第[j]个瓶子里面所获得的最大的美观程度。则状态转移函数可以表示为f[i][j]=max(f[i-1][k]+a[i][j])其中i-1#include #...
分类:
其他好文 时间:
2014-07-13 23:50:22
阅读次数:
323
#include #include int in[9]={1,2,3,4,5,6,7,8,9};int s[9];int re[3][3];int sum(int su[]){ int i,re=0; for(i=0;su[i];i++) re+=su[i]; ret...
分类:
编程语言 时间:
2014-07-13 22:08:59
阅读次数:
342
public class Solution { public int longestConsecutive(int[] num) { HashSet hash=new HashSet(); int max=1; for(int n:num) ...
分类:
其他好文 时间:
2014-07-13 21:52:58
阅读次数:
244
PS::今天巴西又被虐了,做梦以为是3:1,醒来是3:0mysql> delimiter $$mysql> create procedure p3() -> MODIFIES SQL DATA -> BEGIN -> set @i=0; -> set @max=100; ...
分类:
其他好文 时间:
2014-07-13 21:32:50
阅读次数:
195
1. const常量,如const int max = 100; 优点:const常量有数据类型,而宏常量没有数据类型。编译器可以对前者进行类型安全检查,而对后者只进行字符替换,没有类型安全检查,并且在字符替换时可能会产生意料不到的错误。2. const 修饰类的数据成员。 const数据成员只在某...
分类:
编程语言 时间:
2014-07-13 21:29:00
阅读次数:
213
求1~n内所有数对(x,y),gcd(x,y)=质数,的对数。
思路:用f[n]求出,含n的对数,最后用sum【n】求和。
对于gcd(x,y)=a(设x
他们乘积的f[i*a]值包括i的欧拉函数值。时间复杂度(n*质数个数)
#include
#include
using namespace std;
const int maxx=100010;
int mindiv[maxx+5],p...
分类:
其他好文 时间:
2014-07-13 16:45:50
阅读次数:
177
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 following triangle
[
[2],
[3,4],
[...
分类:
其他好文 时间:
2014-07-13 16:01:42
阅读次数:
209
本题就是需要检查有没有负环存在于路径中,使用Bellman Ford算法可以检查是否有负环存在。
算法很简单,就是在Bellman Ford后面增加一个循环判断就可以了。
题目故事很奇怪,小心读题。
#include
#include
#include
const int MAX_N = 501;
const int MAX_M = 2501;
const int MAX_W...
分类:
其他好文 时间:
2014-07-13 15:48:23
阅读次数:
212
HDU1003 Max Sum(求最大字段和)...
分类:
其他好文 时间:
2014-07-13 15:33:13
阅读次数:
180
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary tree and sum
...
分类:
其他好文 时间:
2014-07-13 13:58:01
阅读次数:
184