Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1]...
分类:
其他好文 时间:
2014-08-27 20:26:38
阅读次数:
168
How many Fibs?DescriptionRecall the definition of the Fibonacci numbers:f1 := 1 f2 := 2 fn := fn-1 + fn-2 (n>=3) Given two numbers a and b, calcul...
分类:
其他好文 时间:
2014-08-27 20:17:48
阅读次数:
208
题目链接:uva 1406 - A Sequence of Numbers
题目大意;给定n个数,有两种操作:
Q x:计算与2x取且不为0的数的个数C x:每个数加上x
输出所有Q操作的和。
解题思路:因为x最大为15,所以开16个树状数组,fenx[x]记录的是每个数取模2x+1的情况,然后有一个add值标记总共加了多少。根据add值确定原先数的范围。
#include ...
分类:
其他好文 时间:
2014-08-27 18:47:58
阅读次数:
242
problem: given an array of integers including positive and negative, a target value. find 2 numbers in the array such that the sum of the 2 numbers is...
分类:
其他好文 时间:
2014-08-27 03:53:57
阅读次数:
227
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the following unique perm...
分类:
其他好文 时间:
2014-08-27 01:37:16
阅读次数:
242
思想: 分三种情况: 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