点分治/贪心 对于点分治的理解不够深刻...点分治能统计树上每个点对的信息,那么这里就是统计同种颜色点对之间的最大距离,自然可以用点分 然后点分,每次统计最大距离,但是略微卡常... 还有一种贪心的方法,每种颜色必然选以某点为根最深的节点,计算出最深的节点,然后dfs,看每种颜色,然后和最深的节点计 ...
分类:
其他好文 时间:
2017-08-24 17:56:15
阅读次数:
209
Petra and Jan have just received a box full of free goodies, and want to divide the goodies between them. However, it is not easy to do this fairly, s ...
分类:
其他好文 时间:
2017-08-21 13:27:31
阅读次数:
215
描述 一个最简单的计算器,支持+, -, *, / 四种运算。仅需考虑输入输出为整数的情况,数据和运算结果不会超过int表示的范围。 输入输入只有一行,共有三个参数,其中第1、2个参数为整数,第3个参数为操作符(+,-,*,/)。输出输出只有一行,一个整数,为运算结果。然而:1. 如果出现除数为0的 ...
分类:
其他好文 时间:
2017-08-21 00:15:09
阅读次数:
490
class Solution { public: int divide(int dividend, int divisor) { if (divisor == 0 || (dividend == INT_MIN && divisor == -1)) return INT_MAX; long m = ... ...
分类:
其他好文 时间:
2017-08-19 13:07:49
阅读次数:
142
1305 Pairwise Sum and Divide 题目来源: HackerRank 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 收藏 关注 有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整: fun(A) sum = ...
分类:
其他好文 时间:
2017-08-16 19:15:37
阅读次数:
133
在实际编码中,会遇到很多高精度的事例,比如,在计算金钱的时候就需要保留高精度小数,这样计算才不会有太大误差: 在下面的代码中,我们验证了,当两个float型的数字相加,得到的结果和我们的预期结果是有误差的,为了减小和防止这种误差的出现,我们需要使用BigInteger类和BigDecimal类来计算 ...
分类:
编程语言 时间:
2017-08-14 10:13:06
阅读次数:
168
It is not the mountain we conquer but outselves. 我们要征服的不是高山,而是我们自己。 After days of hard working, I sliding into the idling state again. Looking at the ...
分类:
其他好文 时间:
2017-08-14 00:37:43
阅读次数:
120
Jack has several beautiful diamonds, each of them is unique thus precious. To keep them safe, he wants to divide and store them in different locations ...
分类:
其他好文 时间:
2017-08-13 16:21:44
阅读次数:
213
Divide two integers without using multiplication, division and mod operator. If it is overflow, return 2147483647 Have you met this question in a real ...
分类:
其他好文 时间:
2017-08-10 13:28:17
阅读次数:
137
about Stream 什么是流? Stream是java8中新增加的一个特性,被Java猿统称为流. Stream 不是集合元素,它不是数据结构并不保存数据,它是有关算法和计算的,它更像一个高级版本的 Iterator。原始版本的 Iterator,用户只能显式地一个一个遍历元素并对其执行某些操 ...
分类:
其他好文 时间:
2017-08-09 11:26:49
阅读次数:
238