隐藏转型的问题,对于简单的例子,大家都已经知道:short i=1,j=1;short k = i+j ;//编译错误,需要手工转型 。但是 i++是可以的。这里就涉及隐藏转型的问题。今天优化代码,原来的double用float,有一处没有修改,竟然能正确编译: float sum = 0; float[] location = point.getLocation();...
分类:
其他好文 时间:
2014-08-26 13:49:06
阅读次数:
155
1 //Accepted 368K 532MS 2 //线性dp 3 //dp[i][j]表示前i位最后一个是j的排列数 4 //dp[i][j]=sum(dp[i-1][h]) h*2 6 #include 7 #include 8 using namespace std; 9...
分类:
其他好文 时间:
2014-08-26 13:39:56
阅读次数:
216
POJ 2159
题目归结为判断两个自然数多集(允许有重复元素的集合)a, b是否相等。用快排比较的效率是O(nlgn).
此题中a.b则分别是每个字母个数集。
下面提出一种O(n)的方法供大家参考。
猜想:若 sum(a^i) = sum(b^i),i = 0, 1, 2, 则 a = b。
证明:?
注意
sum(s^0) 是多集s中元素的数目
su...
分类:
其他好文 时间:
2014-08-26 11:49:56
阅读次数:
219
Description
In the late 1700s', Gauss, a famous mathematician, found a special kind of numbers. These integers are all in the form:
a + b .The sum and multiplication ofthese integers can be natura...
分类:
其他好文 时间:
2014-08-26 11:46:25
阅读次数:
237
用最笨但是最省心的写法…… 1 import java.util.Scanner; 2 3 public class P1068 4 { 5 public static void main(String args[]) 6 { 7 try (Scanner cin ...
分类:
其他好文 时间:
2014-08-26 02:53:25
阅读次数:
155
算是个动态规划,统计和sum[位数][差值]构建个虚拟数组写起来就顺多了 1 import java.util.Scanner; 2 3 public class P1044 4 { 5 private static int save[][] = new int[10][100]; 6 ...
分类:
其他好文 时间:
2014-08-26 02:53:05
阅读次数:
243
In one well-known algorithm of finding the k-th order statistics we should divide all elements into groups of five consecutive elements and find the median
of each five. A median is called the middl...
分类:
其他好文 时间:
2014-08-25 22:50:55
阅读次数:
297
LeetCode: TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For exa...
分类:
其他好文 时间:
2014-08-25 22:48:14
阅读次数:
306
LeetCode: Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree. For example:G...
分类:
其他好文 时间:
2014-08-25 22:34:54
阅读次数:
184