码迷,mamicode.com
首页 >  
搜索关键字:$max    ( 23629个结果
leetcode Triangle
分析:从最小面一层开始往上计算,设dp[i][j]是以第i层j个元素为起点的最小路径和,动态规划方程如下dp[i][j] = value[i][j] + max{dp[i-1][j], dp[i-1][j+1]}因为每一层之和它下一层的值有关,因此只需要一个一位数组保存下层的值,public int...
分类:其他好文   时间:2014-05-24 05:56:35    阅读次数:294
java StringBuffer,StringBuilder,String自身连接效率对比
当我们仅仅需要a+b 的时候,两个字符串链接任何方法的效率基本一样,都在0.0001毫秒内就可以完成。不过如果需要1万次,10000万次,就会发现string自身的join速度显著下降 package com.java.lang;   public class StringTest { int MAX = 10000; //1万次累加 public String Buffer(){...
分类:编程语言   时间:2014-05-22 13:35:23    阅读次数:299
动态规划问题总结
Robberies http://acm.hdu.edu.cn/showproblem.php?pid=2955      背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢多少钱   最脑残的是把总的概率以为是抢N家银行的概率之和… 把状态转移方程写成了f[j]=max{f[j],f[j-q[i].v]+q[i].money}(f[j]表示在概...
分类:其他好文   时间:2014-05-22 09:43:12    阅读次数:282
最长上升子序列之基础
代码a #include #define maxn 1005 int a[maxn]; int dp[maxn]; int max(int x,int y) {     return x>y?x:y; } int main() {     int t,n;            scanf("%d",&t);...
分类:其他好文   时间:2014-05-22 09:16:47    阅读次数:192
HDU1003 Max Sum 最大子序列和的问题【四种算法分析+实现】
就拿杭电OJ上的第1003题开始吧,这题比原书要复杂一些。 Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum...
分类:其他好文   时间:2014-05-22 07:07:27    阅读次数:322
各种排序算法的一个类
#include #define MAX 100 using namespace std; class Sample {      int a[MAX];       int b[MAX];      int n;      friend class Process;    public:          Sample(){n=0;} }; cla...
分类:其他好文   时间:2014-05-20 15:24:05    阅读次数:345
(void)(&x==&y)
#define max(x,y) ({ typeof(x) _x = (x);    typeof(y) _y = (y);    (void) (&_x == &_y);    _x > _y ? _x : _y; }) typeof(x)的意思是取x的类型,这不是标准C里的,gcc支持,vc不支持 (void) (&_x == &_y);这句话本身从执行程序来讲...
分类:其他好文   时间:2014-05-20 14:58:20    阅读次数:269
Python yield
http://www.ibm.com/developerworks/cn/opensource/os-cn-python-yield/清单 5. 使用 yield 的第四版 def fab(max): n, a, b = 0, 0, 1 while n >> for n in fab...
分类:编程语言   时间:2014-05-20 13:45:03    阅读次数:319
hud 2089 不要62 (数位dp)
#include#include#include#define max 10int dp[max][3];int number[max];//dp[i][0] 前i位数中不符合要求的总个数//dp[i][1] 前i位数中最高位是2的个数//dp[i][2] 前i位数中存在含4和有连续62的个数voi...
分类:其他好文   时间:2014-05-20 13:24:39    阅读次数:252
linqtosql(GroupBy/Having/Count/Sum/Min/Max/Avg操作符)
Group By/Having操作符适用场景:分组数据,为我们查找数据缩小范围。说明:分配并返回对传入参数进行分组操作后的可枚举对象。分组;延迟1.简单形式:var q = from p in db.Products group p by p.CategoryID into g select g;语...
分类:数据库   时间:2014-05-20 07:48:14    阅读次数:531
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!