思想: 分三种情况: 1. 当前结点为空,返回0. 2. 叶子结点, 返回当前值. 3. 父结点,返回左右两个 path 值的和。
分类:
其他好文 时间:
2014-08-27 00:22:06
阅读次数:
194
Humble Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 17407 Accepted Submission(s): 7565
Problem Description
A number w...
分类:
其他好文 时间:
2014-08-26 21:28:16
阅读次数:
296
Description
{p1,..., pk : p1 <
p2 pk} is called a prime
k -tuple of distance s if
p1, p2,..., pk are consecutive prime numbers and
pk - p1 = s . For example, with
k = 4 , s = 8 ,
{11, 13, 1...
分类:
其他好文 时间:
2014-08-26 17:25:13
阅读次数:
217
ROADS
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 10844
Accepted: 3994
Description
N cities named with numbers 1 ... N are connected with one-way roads...
分类:
其他好文 时间:
2014-08-26 17:19:46
阅读次数:
242
给出数n和m,求n的所有排列中,模m得0的有多少个 n
(1?≤?n?18) and
m (1?≤?m?≤?100).
暴力法我们直接枚举n的所有排列,显然18!超时。
考虑怎么dp
假设给了我们数n=23765
显然有
(237%m*10+6)%m=2376%m
(367%m*10+2)%m=3672
我们很自然的想到了
这样的状态转移
dp[i][k]
i代表取...
分类:
其他好文 时间:
2014-08-26 15:38:36
阅读次数:
216
Description
In the late 1700s', Gauss, a famous mathematician, found a special kind of numbers. These integers are all in the form:
a + b .The sum and multiplication ofthese integers can be natura...
分类:
其他好文 时间:
2014-08-26 11:46:25
阅读次数:
237
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define inf 0x3f3f3f3f
#pragma comment(linker, "/STACK:16777216")
#define eps 1e-6
#define ll long l...
分类:
其他好文 时间:
2014-08-25 22:59:45
阅读次数:
524
LeetCode: TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For exa...
分类:
其他好文 时间:
2014-08-25 22:48:14
阅读次数:
306
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl...
分类:
其他好文 时间:
2014-08-25 22:43:04
阅读次数:
266
LeetCode: Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A...
分类:
其他好文 时间:
2014-08-25 22:31:25
阅读次数:
216