码迷,mamicode.com
首页 >  
搜索关键字:k sum    ( 21381个结果
UESTC 886 方老师金币堆
环状合并石子问题。环状无非是第n个要和第1个相邻。可以复制该行石子到原来那行的右边即可达到目的。定义:dp[i][j]代表从第i堆合并至第j堆所要消耗的最小体力。转移方程:dp[i][j]=min(dp[i][k]+dp[k+1][j]+sum[i][j]);复杂度:O(n^3)。可考虑四边形优化。...
分类:其他好文   时间:2014-06-02 20:34:03    阅读次数:226
UESTC 876 爱管闲事
题意:即求给定n个数字(a1,a2,……an),不改变序列,分成M份,使每一份和的乘积最大。思路:dp[i][j]表示把前i个数字,分成j份所能得到的最大乘积。转移方程:dp[i][j] = max{ dp[k][i-1]*sum(k+1,j) } 其中显然j#include #include #i...
分类:其他好文   时间:2014-06-02 19:58:45    阅读次数:242
几道算法题
1.Problem DescriptionGiven 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,-...
分类:其他好文   时间:2014-06-02 17:36:53    阅读次数:234
Amicable numbers -- Javascript 实现
问题描述: Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a  b, then a and b are an amicable pair and each ...
分类:编程语言   时间:2014-06-02 12:31:42    阅读次数:298
scala 常用算法
求和print(Array(1,7,2,9).sum)结果19要使用sum方法,元素类型必须是数值类型:要么是整形,要么是浮点数或者BigInteger/BigDecimal。print(ArrayBuffer("Mary","had","a","little","lamb").max)结果little排序valb=ArrayBuffer(1,7,2,9) valbSorted=b.sorted print(bSorted)..
分类:其他好文   时间:2014-06-02 03:23:26    阅读次数:354
[Oracle] Group By 语句的扩展 - Rollup、Cube和Grouping Sets
经常写SQL语句的人应该知道Group by语句的主要用法是进行分类汇总,下面是一种它最常见的用法(根据部门、职位分别统计业绩): SELECT a.dname,b.job,SUM(b.sal) sum_sal FROM dept a,emp b WHERE a.deptno = b.deptno GROUP BY a.dname,b.job; DNAME JOB...
分类:数据库   时间:2014-06-02 02:28:40    阅读次数:289
leetcode -- 3 sum
3-sum    题目描述: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. 题目要求: Elements...
分类:其他好文   时间:2014-06-01 17:31:27    阅读次数:471
java-第五章-计算100以内(包括100)的偶数之和
publicclassA01{ /** *@paramargs */ publicstaticvoidmain(String[]args){ //TODOAuto-generatedmethodstub intsum=0; intnum=2; while(num<=100){ sum+=num; num+=2; } System.out.println(sum); } }
分类:编程语言   时间:2014-06-01 16:35:36    阅读次数:552
最大m子段和问题 Max Sum Plus Plus —— 动态规划
最大m子段和问题 Max Sum Plus Plus —— 动态规划...
分类:其他好文   时间:2014-06-01 16:18:49    阅读次数:259
ZJ2008树的统计(树链剖分)
type node1=record go,next:longint;end; node2=record l,r,mx,sum:longint;end;var i,x,y,n,q,tmp,cnt,sz,code:longint; ch,st:string; fa:a...
分类:其他好文   时间:2014-06-01 11:45:18    阅读次数:374
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!