码迷,mamicode.com
首页 >  
搜索关键字:max sum plus plus    ( 46271个结果
HDU 4059 The Boss on Mars-矩阵+容斥
错了29遍,终成正果。。。。。 根据题意,很容易的可以想到容斥。 然后的问题就是如何求 sum(n)=1^4+2^4+3^4+....+n^4; 有三种道路: 很显然:1^4+2^4+3^4+....+n^4=(n^5)/5+(n^4)/2+(n^3)/3-n/30; 则1,用java的大数去敲这个的代码。 2,用c++敲,但是用到分数取模,求逆元。 3,用c++敲,但是不用这...
分类:其他好文   时间:2014-05-15 06:36:06    阅读次数:328
[LeetCode] K sum(2Sum、3Sum、4Sum)
2Sum & 3Sum & 4Sum & KSum...
分类:其他好文   时间:2014-05-15 05:33:56    阅读次数:270
leetcode第一刷_Combination Sum Combination Sum II
啊啊啊啊,好怀念这种用递归保存路径然后打印出来的题目啊,好久没遇到了。 分了两种,一种是可以重复使用数组中数字的,一种是每个数字只能用一次的。其实没有多大区别,第一种每次进入递归的时候都要从头开始尝试,第二种要找一个标记的数组,把已经用到过的排除掉,就像生成全排列时的做法一样。跟我一样用引用保存中间结果的话,要注意回退的情况。第二种回退时,要把用到的那个数也恢复为可用,就完全像全排列时做的一样。...
分类:其他好文   时间:2014-05-15 04:46:34    阅读次数:272
LeetCode-001 Two Sum
LeetCode-001 Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2...
分类:其他好文   时间:2014-05-15 04:34:50    阅读次数:293
c++ primer plus(第6版)中文版 第十章编程练习答案
第十章编程练习答案...
分类:编程语言   时间:2014-05-15 04:26:27    阅读次数:423
【LeetCode】Plus One
题目 Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 解答 本题考察进位问题,注...
分类:其他好文   时间:2014-05-15 04:16:56    阅读次数:245
UVALive 6609(Minimal Subarray Length)维护递增序列|RMQ
题意:给一个整数序列(可能有负数),求最短的连续序列使得序列之和大于等于整数x; 解法:第一种是On的复杂度:                   我们要的是sum[j]-sum[i]>=x,如果有两个决策j = sum[j'],那么j就是没用的。即维护一个sum[j]递增序列。然后每次可以二分查找,但是这里有个特点就是要得到最近的,可以同时维护一个left指针,left指针用于跟进更...
分类:其他好文   时间:2014-05-15 03:20:26    阅读次数:303
【mysql案例】mysql5.6.14配置my.cnf多实例,mysql_install_db初始化不读取my.cnf配置文件
mysql5.6.14配置my.cnf多实例,mysql_install_db初始化不读取my.cnf配置文件 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a differentsize 768 pages (rounded down to MB) than specified in the .cnf file: initial65536 pages, max 0 (relevant if non-zero) pages! 2014-0...
分类:数据库   时间:2014-05-14 14:20:48    阅读次数:412
HDU 4635
http://acm.hdu.edu.cn/showproblem.php?pid=4635问:最多加多少条边,使得原图不是强连通图正向考虑有困难,不妨反向思考,既最少去掉几条边使得原图不是强连通。总边数sum=n*(n-1)时肯定是强连通,已经给了m条边,sum-=m这时把已经强连通的部分进行缩点...
分类:其他好文   时间:2014-05-14 13:37:36    阅读次数:335
BZOJ3157: 国王奇遇记 & 3516: 国王奇遇记加强版
令\[S_i=\sum_{k=1}^n k^i m^k\]我们有\[\begin{eqnarray*}(m-1)S_i & = & mS_i - S_i \\& = & \sum_{k=1}^n k^i m^{k+1} - \sum_{k=1}^n k^i m^k \\& = & \sum_{k=2...
分类:其他好文   时间:2014-05-14 10:45:13    阅读次数:357
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!