题目链接:Codeforces 486D Valid Sets
题目大意:给定一棵树,每个节点有个权值,现在要选定一些节点,要求非空,并且maxVal-minVal不大于d。问说有多
少种选择方法。
解题思路:枚举每个节点作为根节点,默认根节点为权值最大的节点,然后各个孩子节点用乘法原理即可。
#include
#include
#include
#include
u...
分类:
其他好文 时间:
2014-11-13 14:49:38
阅读次数:
185
Validate if a given string is numeric.
Some examples:
"0" => true
" 0.1 " => true
"abc" => false
"1 a" => false
"2e10" => true
Note: It is intended for the problem statement to be ambiguo...
分类:
其他好文 时间:
2014-11-12 19:45:35
阅读次数:
201
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.
The Sudoku board could be partially filled, where empty cells are filled with the character '.'.
A partially fille...
分类:
其他好文 时间:
2014-11-12 17:55:20
阅读次数:
189
目前在学习Socket,因为和IO关系紧密,于是顺便也学了下IO
发现有这样一句话:
The flush method is valid on any output stream,but has no effect unless the stream is buffered
这句话意思是所有的输出流都有flush方法,但是仅对缓冲流有效
看到这里,笔者想到了自己写的serversocket...
分类:
编程语言 时间:
2014-11-12 11:53:08
阅读次数:
278
Length of Last WordGiven a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.I...
分类:
其他好文 时间:
2014-11-12 00:22:45
阅读次数:
215
给定一组字符串,按照给定长度(eg.16)格式化显示,使每一行尽可能多的单词,单词之间的空格均衡-最左侧可以稍多
左右对齐。最后一行靠左对齐,即最右侧可以没有但系。
Given an array of words and a length L, format the text such that each line has exactly L characters and is ful...
分类:
编程语言 时间:
2014-11-11 22:54:44
阅读次数:
237
Valid ParenthesesGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must clos...
分类:
其他好文 时间:
2014-11-11 22:24:21
阅读次数:
201
Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe...
分类:
其他好文 时间:
2014-11-10 06:30:52
阅读次数:
238
Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express...
分类:
其他好文 时间:
2014-11-09 20:44:22
阅读次数:
204
leetcode的第一题,回文数判断。原题如下:For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome.Note: Have you consider that t...
分类:
其他好文 时间:
2014-11-09 19:33:04
阅读次数:
300