我是个逗比。。。真心不是搞算法的料
不太中规中矩的分组背包,分组至少选一件商品。dp[i][j] 可以由当前dp[i-1][j-c] 和 dp[ i ][j-c]更新得到。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#pragma comment(link...
分类:
其他好文 时间:
2014-05-10 09:10:20
阅读次数:
301
http://acm.hdu.edu.cn/showproblem.php?pid=3033
大致题意:某人要买鞋子,有k种鞋,要求每种鞋至少买一双,给出每双鞋子的花费和价值,问m元钱可以买到的鞋子的最大价值是多少。
思路:分组背包问题。与传统的分组背包不同:每组物品至少取一件;且每组中物品任意取。
想一想传统的分组背包,每组至多选一件:
for 所有的组k
fo...
分类:
其他好文 时间:
2014-05-10 08:48:59
阅读次数:
325
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-05-08 21:08:25
阅读次数:
407
Chef and The Right Triangles
The Chef is given a list of N triangles. Each triangle is identfied by the coordinates of its three corners in the 2-D cartesian plane. His job is to figure out how m...
分类:
其他好文 时间:
2014-05-07 16:28:35
阅读次数:
314
找出一个数组中的三个数,三个数不能组成三角形。
三个数不能组成三角形的条件是:a + b
两边和小于第三边。
这个问题属于三个数的组合问题了。暴力法可解,但是时间效率就是O(n*n*n)了,很慢。
不过既然是组合问题就必定可以使用排序后处理的方法降低时间效率的。
这里降低时间效率的方法是:
选一个最大的数c,然后选两个小数a和b,其中a
这样可以把时间效率降到O(n*n)...
分类:
其他好文 时间:
2014-05-07 06:32:23
阅读次数:
289
The number of steps
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
Mary stands in a strange maze, the maze looks like a triangle(the first layer have one room,the seco...
分类:
其他好文 时间:
2014-05-07 06:15:59
阅读次数:
427
最近在学scala语言,scala代码如下:
import scala.collection.JavaConversions._
object Solution {
def solution(A: Array[Int]): Int = {
// write your code in Scala 2.10
// sort
scala.uti...
分类:
其他好文 时间:
2014-05-07 04:20:38
阅读次数:
352
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-05-07 02:55:24
阅读次数:
377
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4631
Sad Love Story
Time Limit: 40000/20000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 1590 Accepted S...
分类:
其他好文 时间:
2014-05-07 02:40:43
阅读次数:
376
Problem:The sequence of triangle numbers is
generated by adding the natural numbers. So the 7thtriangle number would be 1 +
2 + 3 + 4 + 5 + 6 + 7 = 28...
分类:
其他好文 时间:
2014-05-07 00:28:01
阅读次数:
365