Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.
The teacher has written down the sum of multiple numbers. Pupils should ca...
分类:
其他好文 时间:
2014-07-22 23:05:53
阅读次数:
382
题目链接:1484 - Alice and Bob's Trip
题意:BOB和ALICE这对狗男女在一颗树上走,BOB先走,BOB要尽量使得总路径权和大,ALICE要小,但是有个条件,就是路径权值总和必须在[L,R]之间,求最终这条路径的权值。
思路:树形dp,dp[u]表示在u结点的权值,往下dfs的时候顺带记录下到根节点的权值总和,然后如果dp[v] + w + sum 在[l,r]内,...
分类:
其他好文 时间:
2014-07-22 23:05:33
阅读次数:
486
16、Power digit sum215= 32768 and the sum of its
digits is 3 + 2 + 7 + 6 + 8 = 26.What is the sum of the digits of the number
21000?题目大意:215= 32768 并且其...
分类:
其他好文 时间:
2014-05-02 13:17:49
阅读次数:
1223
题目大意:先给定n个数字,现在要求算出这n个数字的两两之和保存到sum数组,然后在给定m个数,要求找到和每一个数最接近的sum[i];
挨个计算每个属于其他数之间的sum,然后排序;
查找时有两种方法:二分查找&&双向查找;当然二分查找的效率比后者高了很多,但是都能AC。
提供一条新思路,并不一定非要用二分。
双向查找:
#include
#include
#include
using ...
分类:
其他好文 时间:
2014-05-01 18:43:34
阅读次数:
256
题目链接:
http://poj.org/problem?id=1707
Language:
Default
Sum of powers
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 735
Accepted: 354
D...
分类:
其他好文 时间:
2014-05-01 18:36:32
阅读次数:
385
链接:http://acm.hdu.edu.cn/showproblem.php?pid=3415
题意:给出一个数环,要找出其中9长度小于等于K的和最大的子段。
思路:不能采用最暴力的枚举,题目的数据量是10^5,O(N^2)的枚举回去超时,本题采用的很巧妙的DP做法,是用单调队列优化的DP。
运用的是STL的deque,从i:1~a找到以其中以i为尾的符合条件的子段,并将i本身放入双向队...
分类:
其他好文 时间:
2014-05-01 08:32:53
阅读次数:
324
//由于函数是对象,所以可以直接把函数通过参数传递进来;也可以把函数作为返回值。
function calFun(fun,arg){
//第一个参数就是函数对象
return fun(arg);
}
function sum(num){
return num+100;
}
function say(str){
alert("hello "+str);
}
//...
分类:
Web程序 时间:
2014-04-30 22:41:38
阅读次数:
324
--跟踪文件读入到表中分析
SELECT * INTO ZGSJY
FROM fn_trace_gettable('E:\wxxcdbprofiler.trc', default);
--某时间内,最耗时SQL
select TOP 100 SUBSTRING(Textdata,1,660) as '名称',
count(*) as '数量', sum(duration/1000) as '总执行...
分类:
数据库 时间:
2014-04-30 22:37:39
阅读次数:
327
Max Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 135262 Accepted Submission(s): 31311
Problem Description
Given a sequen...
分类:
其他好文 时间:
2014-04-30 22:21:40
阅读次数:
280
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
思路同十进制的大数相加。代码如下:
class Solution {
public:
string addBinary(string a, str...
分类:
其他好文 时间:
2014-04-29 13:12:20
阅读次数:
328