码迷,mamicode.com
首页 >  
搜索关键字:k sum    ( 21381个结果
codeforces159D - Palindrome pairs 二重DP
题意:给你一个字符串,问你其中不重叠的回文字串对有多少解题思路:这题用到两种方法,不过其实是一个很巧妙的二重dp1)暴力求解以i开头,j结尾的是否为回文,如果是,ans += sum[i-1](ans 为答案, sum[i]为在 1 - i内回文串的个数--需要dp求解)这里非常耗时,时间大约为 n...
分类:其他好文   时间:2014-07-30 20:05:44    阅读次数:276
POJ 2029 DP || 暴力
在大矩形中找一个小矩形 使小矩形包含的*最多 暴力或者DP  水题 暴力: #include "stdio.h" #include "string.h" int main() { int n,m,w,i,s,t,j,k,l,ans,sum,x,y; int map[101][101]; while (scanf("%d",&w)!=EOF) ...
分类:其他好文   时间:2014-07-30 17:44:24    阅读次数:201
A + B Problem II(杭电1002)
/*A + B Problem II Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.   Input The first line of the input contains an...
分类:其他好文   时间:2014-07-30 17:38:54    阅读次数:306
hdu4893 Wow! Such Sequence!
线段树结点上保存一个一般的sum值,再同时保存一个fbsum,表示这个结点表示的一段数字若为斐波那契数时的和 当进行3操作时,只用将sum = fbsum即可 其他操作照常进行,只是单点更新的时候也要先向下更新 #include #include #include #include #include #include #include #include #includ...
分类:其他好文   时间:2014-07-30 17:33:24    阅读次数:153
字符串计算表达式
string str="4+4+2.1";要的效果: double sum=4+4+2.1;方案一:动态计算表达式: 1 public class Expression 2 { 3 object instance; 4 MethodInfo method; ...
分类:其他好文   时间:2014-07-30 14:42:33    阅读次数:250
2014 summer 知识点总结1之线段树
HDU 1166【题意】:n个阵营一字排开,每个初始有a[i]个人。现有两种操作:Q a b 查询[a,b]之间总人数并输出A/S a b 在a号位添加/删除b个人【分析】:最基本的单点更新和区间查询,维护节点信息sum[o]【代码】: 1 #include 2 #include 3 #incl.....
分类:其他好文   时间:2014-07-30 11:56:23    阅读次数:450
[LeetCode] Sum Root to Leaf Numbers(bfs)
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which...
分类:其他好文   时间:2014-07-30 11:30:33    阅读次数:247
HDU 4893 Wow! Such Sequence!(线段树)
很典型的线段树,注意就是一个数字如果变成了斐波那契数字之后如果在change的话,它是不会反生改变的,因为最近的斐波那契数字就是它本身了啊。 用一个flag表示这一段上的数字是否change过,如果flag == 1已经change过,就不会在向下更新。否则的话就进行更新,最后会到达一个节点,更新这个节点。这里用暴力更新就行,找到最近的斐波那契数字。 Add就是一个点更新,sum求和就是一个区...
分类:其他好文   时间:2014-07-30 10:07:43    阅读次数:438
Wow! Such Sequence!
n个点,每个初始值为零,m个操作,共三种操作: 1 k d - "add" 2 l r - "query sum" 3 l r - "change to nearest Fibonacci" 1 ≤ n ≤ 100000, 1 ≤ m ≤ 100000, |d| < 231...
分类:其他好文   时间:2014-07-30 10:03:53    阅读次数:246
Maximum Subarray leetcode java
题目: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [?2,1,?3,4,?1...
分类:编程语言   时间:2014-07-30 05:34:43    阅读次数:319
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!