本月博客排行
-
第1名
Xeden -
第2名
fantaxy025025 -
第3名
bosschen - paulwong
- johnsmith9th
年度博客排行
-
第1名
青否云后端云 -
第2名
宏天软件 -
第3名
gashero - gengyun12
- wy_19921005
- vipbooks
- e_e
- benladeng5225
- ranbuijj
- wallimn
- javashop
- jickcai
- fantaxy025025
- zw7534313
- qepwqnp
- robotmen
- 解宜然
- ssydxa219
- sam123456gz
- zysnba
- sichunli_030
- tanling8334
- arpenker
- gaojingsong
- xpenxpen
- kaizi1992
- wiseboyloves
- jh108020
- xyuma
- ganxueyun
- wangchen.ily
- xiangjie88
- Jameslyy
- luxurioust
- mengjichen
- lemonhandsome
- jbosscn
- nychen2000
- zxq_2017
- lzyfn123
- wjianwei666
- forestqqqq
- ajinn
- siemens800
- hanbaohong
- 狂盗一枝梅
- java-007
- zhanjia
- 喧嚣求静
- Xeden
最新文章列表
Leetcode - Climbing Stairs
[题目]
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
[分析] 一维动态规划入门题
public ...
Leetcode - Unique Binary Search Trees
[题目]
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
For example,Given n = 3, there are a total of 5 unique BST's.
[分析] n个节点的BST的结构数等于从1到n依次为root节点对应的 ...
Leetcode - Maximum Product Subarray
[题目] Find the contiguous subarray within an array (containing at least one number) which has the largest product.
For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges ...
Leetcode - House Robber
[题目] You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent ...
Least Jumps of Frog Cross River
Question:
跳河问题。给一个0/1数组R代表一条河,0代表水,1代表石头。起始位置R[0]等于1,初速度为1. 每一步可以选择以当前速度移动,或者当前速度加1再移动。只能停留在石头上。问最少几步可以跳完整条河流。给定数组为R=[1,1,1,0,1,1,0,0],最少3步能过河:第一步先提速到2,再跳到R[2];第二步先提速到3,再跳到R[5];第三步保持速度3,跳出数组范围,成功过河。 ...
LeetCode - Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",
R ...
Dynamic Programming - Integer Knapsack
Reference: https://web.cs.ship.edu/~tbriggs/dynamic/
The Integer Knapsack problem is a famous rubrick in Computer Science. The problem has a simple brute-force solution. However, solving large ins ...
A Greedy Knapsack Heuristic
1. Strategies for NP-Complete Problems
-- Identify computationally tractable special cases.
- knapsack capacity W = polynomial in number of items n
-- Heuristics
- Pret ...
Exact Algorithms for NP-Complete Problems
1. The Vertex Cover Problem
-- Input: An undirected graph G = (V , E).
-- Goal: Compute a minimum-cardinality vertex cover -- a subset S subset of V that contains at least one endpoint o ...
Optimal Binary Search Trees
1. Problem Denition
-- Input: Frequencies p1, p2, ... , pn for items 1, 2, ... , n. [Assume items in sorted order, 1 < 2 < ... < n]
-- Goal: Compute a valid search tree that min ...
Sequence Alignment
1. Problem Definition:
a) Input: Strings X = x1 ... xm, Y = y1 ... yn over some alphabet Sigma (like {A,C,G,T})
b) Penalty Pgap for inserting a gap, Pab for matching a & b [presumably ...
The Knapsack Problem
1. Problem Denition
-- Input: n items. Each has a:
a) Value vi (nonnegative)
b) Size wi (nonnegative and integral)
Capacity W (a nonnegative integer)
-- Output ...
Introduction to Dynamic Programming and Weighed Independent Set in Graph
1. Problem Definition of WIS in Graph:
-- Input: A path graph G = (V , E) with nonnegative weights on vertices.
-- Output: Subset of nonadjacent vertices (an independent set ) of maximum ...
动态规划(dynamic programming)
方法概述: 发展及研究内容
动态规划(dynamic programming)是运筹学的一个分支,20世纪50年代初美国数学家R.E.Bellman等人在研究多阶段决策过程(multistep decision process)的优化问题时,提出了著名的最优化原理(principle of optimality),把多阶段过程转化为一系列单阶段问题,逐个求解,创立了解决这类过程优化问题的新方法—— ...
hdu 4354 Missile
被坑了!!10^9 - (-10^9) 会超过 0x3f3f3f3f , 搞的我 2 2 2 0 999999999 1 -999999999 2 这组直接输出 - 1
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<q ...
light oj 1128 倍增法LCA + DP
题意:一棵树,每个点都有一个点权,给你q个询问a b,求a到根节点的路径中点权大于等于b且最接近根节点的点编号
刚开始想用树链剖分搞,后来听说用倍增+DP也行
做法:
如果懂倍增法求祖先的方法的话,那么这个DP就能很快理解了,详情见代码
dp[i][j]表示i到i的2^j祖先的路径上的点权的最大值
那么在找的时候只需要log(n)的复杂度就可以找到最上面的点权大于等于b的啦 ...