上一页 1 2 3 4 5 6 7 8 ··· 13 下一页
摘要: 有些HDOJ上的题目明明已经到O(n)算法了,比如1029题,时间复杂度已经最优了,但还是会TLE。主要原因是java的IO不够快。比如input是这样格式的:51 3 2 3 3111 1 1 1 1 5 5 5 5 5 571 1 1 1 1 1 1读每一组数据的时候,最好不要用sc.nextI... 阅读全文
posted @ 2014-12-23 04:21 zmiao 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 最小公倍数least common multiple (LCM).最大公约数greatest common divisor (GCD).代码如下: public static int lcm(int a, int b){ return a*b/gcd(a,b); } ... 阅读全文
posted @ 2014-12-22 13:15 zmiao 阅读(148) 评论(0) 推荐(0) 编辑
摘要: just use the java's printf function. It is like C's printf.System.out.printf("%.3f\n", x); 阅读全文
posted @ 2014-12-20 09:48 zmiao 阅读(105) 评论(0) 推荐(0) 编辑
摘要: Division by 3.发现一些规律:一个数的数字和相加能被三整除,那么这个数也能被3整除。(1)然后可以发现:连续三个整数并排在一起组成的数的数字和必然能被3整除。(2)最后通过(2)总结出:1.题目中的第3K个数,必然能被三整除。2.题目中的第3K + 1个数,其第2个数字到最末一个数字之和... 阅读全文
posted @ 2014-12-17 04:58 zmiao 阅读(125) 评论(0) 推荐(0) 编辑
摘要: it seems all stop methods of thread have been deprecated by java. so how to stop a thread then? it is actually simple, just use a boolean variable.pub... 阅读全文
posted @ 2014-12-06 07:49 zmiao 阅读(151) 评论(0) 推荐(0) 编辑
摘要: It’s easy to see that Paxos does have a failure mode. When two proposers are active at the same time, they may ‘duel’ for highest proposal number by a... 阅读全文
posted @ 2014-11-18 03:39 zmiao 阅读(111) 评论(0) 推荐(0) 编辑
摘要: same question as:why is PAXOS necessary?1, what if >1 nodes become leaders simultaneously?that's why we need phase#1 (prepare) to select a leader.2, w... 阅读全文
posted @ 2014-11-16 07:40 zmiao 阅读(118) 评论(0) 推荐(0) 编辑
摘要: Problem:given an array that contains duplicates (except one value), find the one value that does not have a duplicate in that array. Explain the compl... 阅读全文
posted @ 2014-11-15 03:37 zmiao 阅读(194) 评论(0) 推荐(0) 编辑
摘要: given several intervals, how to find a interval which is a intersect of the most number of the given intervals?Method:Step1: Represent eachreturnedint... 阅读全文
posted @ 2014-11-14 11:10 zmiao 阅读(208) 评论(0) 推荐(0) 编辑
摘要: function gcd(a, b) if b = 0 return a else return gcd(b, a mod b) 阅读全文
posted @ 2014-11-13 12:56 zmiao 阅读(121) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 13 下一页