方法命名约定 之前在学习《运算符重载》一节时曾经说过一个方法命名约定:方法的第一个字符决定了方法的优先级。现在再说另一个命名约定:如果方法以冒号(:)结尾,则调用目标是运算符后面的实例。 比如下面这个例子: class Cow { def ^(moon: Moon) = println("Cow j... ...
分类:
其他好文 时间:
2016-09-16 00:14:01
阅读次数:
182
Description Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow ...
分类:
其他好文 时间:
2016-09-11 20:23:53
阅读次数:
698
Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 76935 Accepted: 24323 Description Farmer John has been informed of the locat ...
分类:
Web程序 时间:
2016-09-10 00:05:04
阅读次数:
220
最优化问题 常规动态规划 SOJ1162 I-Keyboard SOJ1685 Chopsticks SOJ1679 Gangsters SOJ2096 Maximum Submatrix SOJ2111 littleken bg SOJ2142 Cow Exhibition SOJ2505 The ...
分类:
其他好文 时间:
2016-09-09 06:30:00
阅读次数:
266
CopyOnWrite(COW):写时拷贝技术一、什么是写时拷贝技术:写时拷贝技术可以理解为“写的时候才去分配空间”,这实际上是一种拖延战术。举个栗子:二、写时拷贝技术原理:写时拷贝技术是通过"引用计数"实现的,在分配空间的时候多分配4个字节,用来记录有多少个指针指向块空间,..
分类:
其他好文 时间:
2016-09-06 23:32:37
阅读次数:
329
Milking Time Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8048 Accepted: 3388 Description Bessie is such a hard-working cow. In fact, sh ...
分类:
其他好文 时间:
2016-09-04 19:13:18
阅读次数:
200
题目大意:给出n个数的序列,每次可以交换相邻的两个数,问把序列变成编号i在编号i+1左边,编号1在编号n右边(一个环)最少需要多少步。如:35421最少交换两次变为34512。 一开始看到这题,只会O(n²),后来仔细想了一下,妙啊,妙不可言。 首先我们求出逆序对,即为这个序列变成升序排列的最小次数 ...
分类:
其他好文 时间:
2016-09-03 16:25:02
阅读次数:
337
Description Bessie the cow is trying to type a balanced string of parentheses into her new laptop, but she is sufficiently clumsy (due to her large ho ...
分类:
其他好文 时间:
2016-09-02 08:46:27
阅读次数:
204
Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00 ...
分类:
其他好文 时间:
2016-08-30 18:02:04
阅读次数:
114
题意:给定一行字符串,让你把它变成字典序最短,方法只有两种,要么从头部拿一个字符,要么从尾部拿一个。 析:贪心,从两边拿时,哪个小先拿哪个,如果一样,接着往下比较,要么比到字符不一样,要么比完,也就是说从头部和尾部拿都一样,那么就随便拿一个了。 代码如下: ...
分类:
其他好文 时间:
2016-08-30 00:32:26
阅读次数:
147