码迷,mamicode.com
首页 >  
搜索关键字:k sum    ( 21381个结果
WhileTest
public class WhileTest { //求100以内6的倍数的个数。 public static void main (String[] args){ int x = 1; int sum =0; while(x*6<101){ s...
分类:其他好文   时间:2014-08-16 11:09:20    阅读次数:200
题目590-相同的和-nyoj20140816
#includeint main(){int n,a,b[1010],i,j,cnt,sum;while(scanf("%d%d",&n,&a)!=EOF){cnt=0;for(i=0;i//#include int main(){ int m,n; int a[100]; int sum,k,i,...
分类:其他好文   时间:2014-08-16 11:06:50    阅读次数:182
[leetcode]Minimum Path Sum
Minimum Path SumGiven amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along ...
分类:其他好文   时间:2014-08-16 02:13:49    阅读次数:189
[leetcode]Sum Root to Leaf Numbers
Sum Root to Leaf NumbersGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-l...
分类:其他好文   时间:2014-08-16 00:59:09    阅读次数:197
while语句求和。
public class WhileDemo {/*求1-10的和*/ public static void main (String[] args ){ int x = 1 ; int sum = 0; while(x<11){ sum=sum+x; ...
分类:其他好文   时间:2014-08-15 23:48:59    阅读次数:225
Triangle
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-08-15 23:47:19    阅读次数:302
{POJ}{动态规划}
动态规划与贪心相关:{POJ}{2479}{Maximum Sum} (DP)摘要: 题意:给定n个数,求两段连续子列的最大和。思路:先从左向右dp,求出一段连续子列的最大和,再从右向左dp,求出两段连续子列的最大和,方法还是挺经典的。{POJ}{1036}{Gansters} (DP)摘要: 题意...
分类:其他好文   时间:2014-08-15 22:20:09    阅读次数:309
3Sum Closest
Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m...
分类:其他好文   时间:2014-08-15 20:53:19    阅读次数:240
【UVA】1210 - Sum of Consecutive Prime Numbers
普通的求区间连续和的问题,一开始因为是区间移动,但是怕UVA数据太严,直接打表,后来发现自己的担心是多余的。 14044972 1210 Sum of Consecutive Prime Numbers Accepted C++ 0.049 2014-08-15 10:30:11 打表的话效率可能不是很高. AC代码:...
分类:其他好文   时间:2014-08-15 19:43:29    阅读次数:182
【HackerRank】Pairs
题目链接:Pairs完全就是Two Sum问题的变形!Two Sum问题是要求数组中和正好等于K的两个数,这个是求数组中两个数的差正好等于K的两个数。总结其实就是“骑驴找马”的问题:即当前遍历ar[i],那么只要看数组中是否存在ar[i]+K或者ar[i]-K就可以了,还是用HashMap在O(1)...
分类:其他好文   时间:2014-08-15 17:17:19    阅读次数:123
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!