题目链接:http://www.spoj.com/problems/COT2/You are given a tree withNnodes.The tree nodes are numbered from1toN.Each node has an integer weight.We will as...
分类:
其他好文 时间:
2015-02-01 18:58:15
阅读次数:
170
从S开始时只能是两种情况:1.现在总和已经是3的倍数了,那么因为每人每次只能拿走一个数,要保持拿走之后依然是3的倍数,那么就只能拿3,6,9这类数,用num统计一下,看看num奇偶性就知道谁最后拿了。2.现在总和不是3的倍数,那么要么除3余1要么除3余2,就用num1和num2分别统计两种单个数的数...
分类:
其他好文 时间:
2015-02-01 17:33:16
阅读次数:
180
First Missing Positive
Total Accepted: 27915 Total
Submissions: 121776My Submissions
Question
Solution
Given an unsorted integer array, find the first missing positive integer.
F...
分类:
其他好文 时间:
2015-02-01 16:13:42
阅读次数:
123
Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express...
分类:
其他好文 时间:
2015-02-01 16:04:04
阅读次数:
125
Discrete Function
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status
Description
There is a discrete function. It is specified for integer arg...
分类:
其他好文 时间:
2015-02-01 13:32:42
阅读次数:
136
short Short 2个字节 int Integer 4个字节long Long 8个字节 float Float 4个字节double Double 8个字节byte Byte 1个字节char Character 2个字节 boolean BooleanJAVA数据类型分基本数据类型和引用数...
分类:
编程语言 时间:
2015-01-31 17:35:20
阅读次数:
263
Description The country of jiuye composed by N cites. Each city can be viewed as a point in a two- dimensional plane with integer coordinates (x,y)...
分类:
其他好文 时间:
2015-01-31 14:18:03
阅读次数:
278
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
HideTags
Math String
class Solution {
public:
string intToRoman(int num)
{
int ...
分类:
其他好文 时间:
2015-01-31 12:49:10
阅读次数:
141
首先简单介绍一下罗马数字,一下摘自维基百科
罗马数字共有7个,即I(1)、V(5)、X(10)、L(50)、C(100)、D(500)和M(1000)。按照下述的规则可以表示任意正整数。需要注意的是罗马数字中没有“0”,与进位制无关。一般认为罗马数字只用来记数,而不作演算。
重复数次:一个罗马数字重复几次,就表示这个数的几倍。右加左减:在较大的罗马数字的右边记上较小的罗马数字,表示大数字加小数...
分类:
其他好文 时间:
2015-01-31 12:48:17
阅读次数:
140
Q:Determine whether an integer is a palindrome. Do this without extra space.
这道题也是基础题,判断一个数是否是回文数,条件是不能使用额外的空间,意思就是说,你不能把一个Intege转换成string,然后对string进行回文字符串的判断。
另外,如果用Reverse Integer的方法,可能会造成数值溢出,比如判...
分类:
其他好文 时间:
2015-01-31 12:31:11
阅读次数:
169