1 collections系列 方法如下 1 class Counter(dict): 2 '''Dict subclass for counting hashable items. Sometimes called a bag 3 or multiset. Elements are stored ...
分类:
编程语言 时间:
2016-09-28 16:24:23
阅读次数:
338
// My own solutionclass Solution { public: vector<int> countBits(int num) { vector<int> ret = {0}; if(num <= 0) return ret; ret.push_back(1); int i = ...
分类:
其他好文 时间:
2016-09-25 13:09:08
阅读次数:
122
Python的GC模块主要运用了“引用计数”(reference counting)来跟踪和回收垃圾。在引用计数的基础上,还可以通过“标记-清除”(mark and sweep)解决容器对象可能产生的循环引用的问题。通过“分代回收”(generation collection)以空间换取时间来进一步 ...
分类:
编程语言 时间:
2016-09-23 21:32:41
阅读次数:
252
bzoj2023[Usaco2005 Nov]Ant Counting 数蚂蚁&&bzoj1630[Usaco2007 Demo]Ant Counting 题意: t个族群,每个族群有ni只蚂蚁,同族群蚂蚁没有区别。问从所有蚂蚁中选出s到b只蚂蚁有多少方案。t≤1000,ni≤100。 题解: dp ...
分类:
其他好文 时间:
2016-09-19 22:24:44
阅读次数:
127
一开始尝试用二叉树,最后用结构 struct node{ int k; int son[101];}; son[i]记录子结点 ...
分类:
编程语言 时间:
2016-09-18 14:57:36
阅读次数:
183
一个长度为N的正整数数组A,给出一个数K以及Q个查询,每个查询包含2个数l和r,对于每个查询输出从A[i]到A[j]中,有多少对数,abs(A[i] - A[j]) <= K(abs表示绝对值)。 Input Output ...
分类:
其他好文 时间:
2016-09-17 12:08:04
阅读次数:
310
bzoj4397[Usaco2015 dec]Breed Counting 题意: 给定一个长度为N的序列,每个位置上的数只可能是1,2,3中的一种。有Q次询问,每次给定两个数a,b,请分别输出区间[a,b]里数字1,2,3的个数。n≤100000,q≤100000。 题解: 裸前缀和。 代码: 2 ...
分类:
其他好文 时间:
2016-09-16 11:30:47
阅读次数:
152
1. Counting Bits Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary rep ...
分类:
其他好文 时间:
2016-09-16 07:51:56
阅读次数:
148
Ant Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4982 Accepted: 1896 Description Bessie was poking around the ant hill one day ...
分类:
其他好文 时间:
2016-09-15 17:49:45
阅读次数:
184