/*sum[root][i]表示root节点的子叶子%3余i的总数 lazy懒惰标记*/ 1 #include 2 #include 3 using namespace std; 4 #define N 400010 5 int sum[N][3],lazy[N]; 6 void pushup(.....
分类:
其他好文 时间:
2014-08-02 17:51:03
阅读次数:
270
Max SumTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 135262Accepted Submission(s): 31311Problem ...
分类:
其他好文 时间:
2014-08-02 15:05:23
阅读次数:
259
题目:已知n个数a[1..n],还有另一个数M,在前n个数中找到差值最小的两个数使得他们的和是M。
分析:数学。排序,找M/2。然后向两边分别扩展即可。
设a[s]是第一个大于M/2的数字,
如果M是偶数,并且存在至少两个M/2,则a[s-1]、a[s-2]一定是M/2;
否则a[s-1] M,从这两点向两边扩展即可...
分类:
其他好文 时间:
2014-08-02 12:57:53
阅读次数:
159
题目大意:
给出一个递推的关系。
这个递推的关系可以求出 s_1 s_2 s_3 .... s_m
然后再告诉一个 k 与 n
求出segma( s_k , s_2*k , s_3*k)...共n项。
思路分析:
首先给出来的是递推关系式。
所以可以用一个矩阵递推出 s [i]...
但是他要的是每隔k的值。
定义s的递推矩阵是 A
SUM = S_k + S_2*...
分类:
其他好文 时间:
2014-08-02 12:49:03
阅读次数:
219
Watson gives an array A1,A2...AN to Sherlock. Then he asks him to find if there exists an element in the array, such that, the sum of elements on its ...
分类:
其他好文 时间:
2014-08-02 12:36:13
阅读次数:
185
Sum It Up
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3944 Accepted Submission(s): 2026
Problem Description
Given a specifie...
分类:
其他好文 时间:
2014-08-02 10:05:03
阅读次数:
307
题目:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1...
分类:
编程语言 时间:
2014-08-02 09:50:13
阅读次数:
232
题目:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each ....
分类:
编程语言 时间:
2014-08-02 01:48:12
阅读次数:
246
题意:从一个n*n的矩阵中找出和最大的子矩阵
思路:最大连续和的求解。我们可以将二维的转化为一维进行计算。sum[i][j]表示以(1, 1)和(i, j)为对角的矩阵的和。之后只要逐个枚举每个可能出现的值,保存最大值即可。
#include
#include
#include
#include
using namespace std;
const int INF ...
分类:
其他好文 时间:
2014-08-01 23:16:52
阅读次数:
283
模板
#include
#include
#include
#include
using namespace std;
void cheng( char *a, char *b, char *sum )
{
int temp[2500];
int lena,lenb,l;
lena=strlen(a);
lenb=strlen(b);
int len = lena + lenb...
分类:
其他好文 时间:
2014-08-01 23:15:52
阅读次数:
309