码迷,mamicode.com
首页 >  
搜索关键字:combination sum    ( 21657个结果
LeetCode: Subsets [078]
class Solution { public: void dfs(vector<vector >&result, vectorcombination, vector&candidates, int kth, int k, int index2add){ // 当前正在确定组合中的第kth个数,将把候选集candidates中index2add索引位的值作为第kth个数加到组合中 combination.push_back(ca...
分类:其他好文   时间:2014-06-07 01:21:47    阅读次数:220
projecteuler---->problem=6----Sum square difference
title: The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence ...
分类:其他好文   时间:2014-06-05 12:03:29    阅读次数:243
hdu 1863 畅通工程
题目:         链接:点击打开链接 题意:         中文题 算法: 思路:         赤裸裸的最小生成树。。 代码: #include #include using namespace std; struct node{ int u,v,w; } e[110]; int p[110]; int n,m,sum,ans; int cmp(node...
分类:其他好文   时间:2014-06-05 03:50:23    阅读次数:232
LeetCode:4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: ...
分类:其他好文   时间:2014-06-05 00:34:06    阅读次数:240
hdu-4578-Transformation-线段树
当一道题目,使用__int64超时,使用int就能A的时候,我想,这个题,不是一个好题。。。。。 add[i]:记录加的lazy标记 mul[i]:记录乘的lazy标记 num[i]:记录数的lazy标记 sum[i][j]:第i段,j次方的和。 除去lazy标记的下放,这完全就是一道水的线段树的题目。。。 lazy标记如何下放呢? 1,首先查看num标记,如果存在,果断下放。 2...
分类:其他好文   时间:2014-06-04 21:41:27    阅读次数:343
HDU基本最*子序列集锦1
最大连续子序列(HDU1003,1231) 最大递增子序列和,sum[i]=max(sum[j])+a[i],j 最长公共子序列,LCS经典算法(HDU1159)。 题解: 实际上,我没看出hdu1003和1231的本质差别,形式上的差别就是记载的东西不一样,一个是记载下标,一个是记载元素。基本就是那么回事吧。很多算法书在讨论时效都会拿这个例子来说明,让大家看到算法的力量,从一个弱渣算法到...
分类:其他好文   时间:2014-06-03 04:19:10    阅读次数:279
ORACLE 按表字段值的不同统计数量
select p.id comperitorId,p.compcorp competitorName, sum(case when c.kindname = 'ATM' then c.num else 0 end) atm, sum(case when c.kindname = 'CRS' then c.num else 0 end) crs, sum(case when c.kindname...
分类:数据库   时间:2014-06-03 03:12:09    阅读次数:211
hdu-1255-覆盖的面积-线段树
记录3个变量。 sum[i]:当前区间被覆盖2次及两次以上的面积。 num[i]:当前区间被覆盖1次及一次以上的面积。 cover[i]:覆盖的lazy标记。 对于每一个区间. 更新操作如下: void push_up(int_now) { if(cover[rt]==0) { num[rt]=num[rt<<1]+num[rt<<1|1]; ...
分类:其他好文   时间:2014-05-31 17:58:57    阅读次数:296
【HDOJ】1394 Minimum Inversion Number
逆序数的性质。1. 暴力解 1 #include 2 3 #define MAXNUM 5005 4 5 int a[MAXNUM]; 6 7 int main() { 8 int n; 9 int i, j, sum, min;10 11 while (scanf(...
分类:其他好文   时间:2014-05-31 07:50:50    阅读次数:170
Aizu 1335 Equal Sum Sets
DescriptionLet us consider sets of positive integers less than or equal ton. Note that all elements of a set are different. Also note that the order o...
分类:其他好文   时间:2014-05-31 05:12:49    阅读次数:246
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!