leetcode3 Two Sum III – Data structure design
Question:Design and implement a TwoSum class. It should support the following operations: add and find.add(input) – Add the number input to an interna...
Two Sum(II和IV)
本文包含leetcode上的Two Sum(Python实现)、Two Sum II - Input array is sorted(Python实现)、Two Sum IV - Input is a BST(Java实现)三个类似的题目,现总结于此。Two SumGiven an array of...
【HDOJ】3473 Minimum Sum
划分树解。主席树解MLE。 /* 3473 */ #include <iostream> #include <sstream> #include <string> #include <map> #include <queue> #inclu...
【leetcode】Binary Tree Maximum Path Sum (medium)
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.找树的最大路径和 注意路径可以从任意点起始和结束。我发现我真的还挺擅长树的题目的,递归不难。就是因为有个...
【HDOJ】【3415】Max Sum of Max-K-sub-sequence
DP/单调队列优化呃……环形链求最大k子段和。首先拆环为链求前缀和……然后单调队列吧<_<,裸题没啥好说的……WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……sigh) //HDOJ 3415 #include<queue> #include<cma...
hdu 5586 sum
Problem DescriptionThere is a number sequence A1,A2....An,you can select a interval [l,r] or not,all the numbers Ai(l≤i≤r) will become f(Ai).f(x)=(189...
LeetCode:Minimum Path Sum(网格最大路径和)
题目链接Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its pa...
【一天一道LeetCode】#112. Path Sum
一天一道LeetCode本系列文章已全部上传至我的github,地址:ZeeCoder‘s Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处(一)题目Given a binary tree and a sum, determine if the tree has...
【LeetCode OJ】Path Sum
Problem Link:http://oj.leetcode.com/problems/path-sum/One solution is to BFS the tree from the root, and for each leaf we check if the path sum equals...
【leetcode】Combination Sum (middle)
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeate...
用golang写的生成文件md5sum,检验文件md5sum
源代码地址: https://github.com/sndnvaps/md5sum-golang
bzoj 3944: Sum【莫比乌斯函数+欧拉函数+杜教筛】
一道杜教筛的板子题。两个都是积性函数,所以做法是一样的。以mu为例,设\( f(n)=\sum_{d|n}\mu(d) g(n)=\sum_{i=1}^{n}f(i) s(n)=\sum_{i=1}^{n}\mu(i) \),然后很显然对于mu\( g(n)=1\),对于phi\( g(n)=n*(...
[原创]leet code - path sum
; ; ; } } ; }};
599. Minimum Index Sum of Two Lists(easy)
Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.You need to he...
4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic...
codeforces 703D D. Mishka and Interesting sum(树状数组)
题目链接:D. Mishka and Interesting sumtime limit per test3.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Mishk...
codeforces 703D Mishka and Interesting sum 偶数亦或 离线+前缀树状数组
题目传送门题目大意:给出n个数字,m次区间询问,每一次区间询问都是询问 l 到 r 之间出现次数为偶数的数 的亦或和。思路:偶数个相同数字亦或得到0,奇数个亦或得到本身,那么如果把一段区间暴力亦或,得到的其实就是出现次数为奇数的数字的亦或和,所以我们希望这段区间内的所有数字出现次数都+1,使奇偶性互...
Codeforces Round #365 (Div. 2) D. Mishka and Interesting sum 离线+线段树
题目链接:http://codeforces.com/contest/703/problem/DD. Mishka and Interesting sumtime limit per test 3.5 secondsmemory limit per test 256 megabytes#### 问题...
Codeforces 703D Mishka and Interesting sum(离线 + 树状数组)
题目链接 Mishka and Interesting sum题意 给定一个数列和$q$个询问,每次询问区间$[l, r]$中出现次数为偶数的所有数的异或和。设区间$[l, r]$的异或和为$s(l, r)$, 区间$[l, r]$中所有出现过的数的异或和为$c(l, r)$那么每个询问的答案为...
CF #365 703D. Mishka and Interesting sum
题目描述D. Mishka and Interesting sum的意思就是给出一个数组,以及若干询问,每次询问某个区间[L, R]之间所有出现过偶数次的数字的异或和。这个东西乍看很像是经典问题,一列数字中所有数字出现偶数次,除了一个数字只出现一次,找出那个只出现过一次的数字。然而这个问题并不是要找...