码迷,mamicode.com
首页 >  
搜索关键字:game of sum    ( 26840个结果
LeetCode OJ - Sum Root to Leaf Numbers
这道题也很简单,只要把二叉树按照宽度优先的策略遍历一遍,就可以解决问题,采用递归方法越是简单。下面是AC代码: 1 /** 2 * Sum Root to Leaf Numbers 3 * 采用递归的方法,宽度遍历 4 */ 5 int result=0; 6...
分类:其他好文   时间:2014-04-28 10:05:40    阅读次数:682
UVA 562 Dividing coins --01背包的变形
01背包的变形。先算出硬币面值的总和,然后此题变成求背包容量为V=sum/2时,能装的最多的硬币,然后将剩余的面值和它相减取一个绝对值就是最小的差值。代码:#include #include #include #include #include using namespace std;#define...
分类:其他好文   时间:2014-04-28 09:53:54    阅读次数:645
sdut 2416:Fruit Ninja II(第三届山东省省赛原题,数学题)
Fruit Ninja IITime Limit: 5000MS Memory limit: 65536K题目描述Have you ever played a popular game named "Fruit Ninja"?Fruit Ninja (known as Fruit Ninja HD ...
分类:其他好文   时间:2014-04-28 05:10:47    阅读次数:582
[C++11新特性]第二篇
0.可变数量参数,可变函数模版,变长模版类 c++98可变数量参数 #include#includedouble SumOfFloat(int count, ...){ va_list ap; double sum=0; va_start(ap,count); for(int i=0;i#inclu...
分类:编程语言   时间:2014-04-28 05:08:44    阅读次数:661
△2013山东省ACM竞赛-Alice and Bob
Alice and BobDescriptionAlice and Bob like playing games very much.Today, they introduce a new game.There is a polynomial like this: (a0*x^(2^0)+1) * ...
分类:其他好文   时间:2014-04-28 02:50:32    阅读次数:357
[leetcode] Add Binary
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".给定两个二进制的字符串,返回他们的和。对于a,b两个二进制字符串,首先通过交换使a的长度小于b...
分类:其他好文   时间:2014-04-28 02:05:20    阅读次数:502
素数求和
#include using namespace std;int fun(int a){ if(a==1) return 0; for(int i=2;i>M; while(M--) { int i,sum=0; cout>N; ...
分类:其他好文   时间:2014-04-27 22:06:54    阅读次数:578
BZOJ1858: [Scoi2010]序列操作
这题我很二的折腾了一下午,唉,还是太弱了。这题的关键在于标记的更新与更新每个点的权值,更新标记我很快就写好了,思路很清晰,但是查找答案就头晕了,在处理下传标记、更新权值中纠结。。。。这题我用sum来记录一段区间内1的个数,lest记录该区间从左往右连续的1的个数,rest记录该区间从右往左连续的1的...
分类:其他好文   时间:2014-04-27 22:01:03    阅读次数:549
[Leetcode] 4Sum
Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ...
分类:其他好文   时间:2014-04-27 20:55:03    阅读次数:567
hdu4104 Discount
给n个数,问最小不能组成的正整数是多少。 数学归纳法。 从sum=0开始,每次考察sum+1>=a[i],则sum+1肯定可以达到,那么sum+a[i]以内的数肯定可以达到。 #include #include #include #include #include #include #include #include #include #define...
分类:其他好文   时间:2014-04-27 20:06:50    阅读次数:554
26840条   上一页 1 ... 2682 2683 2684
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!