摘要: Time Limit: 10 Seconds Memory Limit: 32768 KB In 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any positive integer n, define d(n) to be n pl... 阅读全文
posted @ 2012-03-15 20:02 Gavin Lipeng Ma 阅读(241) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 2 Seconds Memory Limit: 65536 KB Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2,... as shown in the figure. For example, 1, 2, and 3 has be... 阅读全文
posted @ 2012-03-15 16:34 Gavin Lipeng Ma 阅读(317) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 2 Seconds Memory Limit: 65536 KB Professor Robert A. J. Matthews of the Applied Mathematics and Computer Science Department at the University of Aston in Birmingham, England has rece... 阅读全文
posted @ 2012-03-14 21:09 Gavin Lipeng Ma 阅读(446) 评论(0) 推荐(0) 编辑
摘要: 之前在解决一道算法题的时候,应用到set,特意对这个stl的容器类做了一些了解。在我的印象中,set就是一个元素不重复的集合,而事实上也正是这样的。无论从MSDN还是任何其它地方,都会告诉我们set的元素不可以重复。反之,只要元素不重复,就可以顺利的放入到set中。看起来这实在是再清楚不过了,但是仔细想一想的话,就会发现,话说只要不重复的元素就可以被放入到一个set中,但是什么样的元素是不重复的元... 阅读全文
posted @ 2012-03-13 22:03 Gavin Lipeng Ma 阅读(1768) 评论(0) 推荐(1) 编辑
摘要: Time Limit: 10 Seconds Memory Limit: 32768 KB For hundreds of years Fermat's Last Theorem, which stated simply that for n > 2 there exist no integers a, b, c > 1 such that a^n = b^n + c^n, has r... 阅读全文
posted @ 2012-03-13 17:19 Gavin Lipeng Ma 阅读(343) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 2 Seconds Memory Limit: 65536 KB A certain prison contains a long hall of n cells, each right next to each other. Each cell has a prisoner in it, and each cell is locked. One night,... 阅读全文
posted @ 2012-03-13 13:03 Gavin Lipeng Ma 阅读(326) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 2 Seconds Memory Limit: 65536 KBGiven a positive integer n and the odd integer o and the nonnegative integer p such that n = o2^p.Example For n = 24, o = 3 and p = 3.Task Write a program which for each data set:reads a positive integer n, computes the odd integer o and the nonnegative in 阅读全文
posted @ 2012-03-13 10:18 Gavin Lipeng Ma 阅读(344) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 2 Seconds Memory Limit: 65536 KB Given a positive integer n, print out the positions of all 1's in its binary representation. The position of the least significant bit is 0. Examp... 阅读全文
posted @ 2012-03-12 22:52 Gavin Lipeng Ma 阅读(349) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 2 Seconds Memory Limit: 65536 KB You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or the film of the same name by Stanley Kubrick. In it a spaceship is ... 阅读全文
posted @ 2012-03-12 22:08 Gavin Lipeng Ma 阅读(344) 评论(0) 推荐(0) 编辑
摘要: Digital RootsTime Limit: 2 Seconds Memory Limit: 65536 KBBackground The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are 阅读全文
posted @ 2012-03-12 21:49 Gavin Lipeng Ma 阅读(956) 评论(0) 推荐(0) 编辑
摘要: Old BillTime Limit: 2 Seconds Memory Limit: 65536 KBAmong grandfather��s papers a bill was found:72 turkeys $_679_The first and the last digits of the number that obviously represented the total price of those turkeys are replaced here by blanks (denoted _), for they are faded and are now illegible. 阅读全文
posted @ 2012-03-12 20:31 Gavin Lipeng Ma 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 在项目开发过程中,经常会写一些工具类。这些类里面,其实什么具体业务也没有做,只是为一些逻辑和算法提供了一些实现。比如一些格式化字符串的操作,获取连接字符串的操作等等。为了让这些方法通用,能够非常方便的... 阅读全文
posted @ 2012-03-07 13:25 Gavin Lipeng Ma 阅读(369) 评论(0) 推荐(1) 编辑
摘要: 这两天比较闲,没有什么事情做。有一次在网上逛的时候,看到了一篇关于“java初学者JDK”的安装和环境变量的设置的文章。在讲到用户变量和系统变量的时候想到,其实系统在寻找应用程序的时候是按照%Syst... 阅读全文
posted @ 2012-03-07 12:41 Gavin Lipeng Ma 阅读(853) 评论(0) 推荐(0) 编辑
摘要: 在程序设计中,最重要的没过月函数原型的定义了。为了程序的灵活性和可维护性,往往在开发的过程中会设计很多子程序来实现独立的一部分内容,然后通过函数调用的方式将各个子程序组合到一块儿,以实现一个完整的程序。这样做确实可以带来很多便利,但是值得重视的是,为了能够享受到这种便利,我们需要在前期做函数原型定义的时候花大量的时间让函数的原型尽量完满,尽可能避免在后期开发的时候改动一个函数的原型。因为一个函数的原型,定义完成之后,对于调用它的其它函数来说,就是一个接口。而当一个被定义的函数接口大量被调用,而实现代码复用和高可维护性与灵活性的程序时,如果发现原型定义有问题,那么用户修改函数原型的开销,将达到一 阅读全文
posted @ 2012-02-20 09:37 Gavin Lipeng Ma 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 阳历新年已经过去了,过的无比的平淡。平淡的一点过节的气氛都没有,唯一让我感觉到在过节,是我休息了三天。2011年久这样没了,有人说2012来了,是啊,2012来了,谁说不是呢。2012总是要来的。 偶尔一次在微博上看到这样一句话:”2012年的一月份,就只有两件事情:一、放假;二、等待放假“。这听起来是多么美好的事情。多么希望可以放个长假,就想小时候一样,什么都不用想,什么都不用做,需要做的,仅... 阅读全文
posted @ 2012-01-06 21:58 Gavin Lipeng Ma 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 闲来无事,又开始翻阅java的有关书籍。看到讲访问权限控制的地方的时候,有一句话大概是这个意思不要轻易返回对私有对象的引用。刚开始的时候,我还不以为意,谁会这么做啊,这不等于把私有对象的控制权交出去了吗?但是当我想到,java对一切的传递都是引用传递的时候,尝试了如下代码: import java.util.Vector;class Test{ private Vector<String> v... 阅读全文
posted @ 2011-10-23 19:33 Gavin Lipeng Ma 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 面向对象程序设计最重要的一点,就是对象的设计。设计好了对象,所有的工作,至少可以说是已经完成了一半。当然,我说的是一个完整的对象,并不是仅仅只有定义,也要有实现才行。 最近,我又开始翻看《java编程思想》等一些面向对象程序设计的一些书,当看到对对象的描述的时候,不禁开始思考:在设计对象的时候,什么才是最重要的呢?首先,一个对象是由其属性和行为组成的。有些地方喜欢说是成员——成员变量和成员函数,... 阅读全文
posted @ 2011-10-19 13:06 Gavin Lipeng Ma 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 不知不觉离开学校已经有一年多了,对,我是2010年6月份毕业的,慢慢的已经淡忘了那种学习的状态。现在想起来还是挺怀念的,也许是工作的原因,也有可能是个人的原因,反正现在的我已经很难再静下心来学习一些东西了。原先的一些打算,现在也都没有开始执行。其实开始工作了,就已经很少去关注一些很书面的知识性的东西了。不在去计较到底什么是“对象”,什么是面向对象,什么是内存管理,只是按照大家的经验,那样做就是了。... 阅读全文
posted @ 2011-09-29 00:12 Gavin Lipeng Ma 阅读(310) 评论(2) 推荐(0) 编辑
摘要: Time Limit: 1 Second Memory Limit: 32768 KB To prepare for programming contests or coding examinations, the judge sometimes has to generate random passwords for the users. The problem is tha... 阅读全文
posted @ 2011-09-27 21:46 Gavin Lipeng Ma 阅读(247) 评论(0) 推荐(0) 编辑
摘要: ConversionsTime Limit:1 Second Memory Limit:32768 KBConversion between the metric and English measurement systems is relatively simple. Often, it involves either multiplying or dividing by a constant. You must write a program that converts between the following units:TypeMetricEnglishequivalentWeigh 阅读全文
posted @ 2011-07-09 15:08 Gavin Lipeng Ma 阅读(419) 评论(0) 推荐(0) 编辑
摘要: Kinds of FuwasTime Limit:1 Second Memory Limit:32768 KBIn the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China as well as becoming a festival for people all over the world.The official mascots of Beijing 2008 Olympic Games are Fuwa, which are named 阅读全文
posted @ 2011-07-09 14:35 Gavin Lipeng Ma 阅读(599) 评论(0) 推荐(0) 编辑
摘要: Find All M^N PleaseTime Limit:1 Second Memory Limit:32768 KBRecently, Joey has special interest in the positive numbers that could be represented asM^N(Mto the powerN), whereMandNare both positive integers greater than or equal to 2. For example, 4, 8, 9 and 16 are first four such numbers, as 4 = 2 阅读全文
posted @ 2011-07-07 21:20 Gavin Lipeng Ma 阅读(437) 评论(0) 推荐(0) 编辑
摘要: 在java中有好几种方法可以把一个对象转换成字符串类型,当然每种方法都有自己的用处,但是如果对几种方法的理解不当的话,也可能给debug带来很大的麻烦,最主要是因为这类bug不容易发现,当前我就碰到了,所有写一下记录下来,警戒自己也同路过的朋友们分享一下。大多数类型都会重写toString方法,这个方法当然是首选的转换成字符串的方法,因为他它方便。用这个方法时,主要要注意空指针错误。当对一个对象为null时,调用其toString方法,将得到该错误。 阅读全文
posted @ 2011-07-05 11:18 Gavin Lipeng Ma 阅读(535) 评论(0) 推荐(0) 编辑
摘要: Easy TaskTime Limit:1 Second Memory Limit:32768 KBCalculating the derivation of a polynomial is an easy task. Given a function f(x) , we use (f(x))' to denote its derivation. We use x^n to denote xn. To calculate the derivation of a polynomial, you should know 3 rules:(1) (C)'=0 where C is a 阅读全文
posted @ 2011-07-04 12:49 Gavin Lipeng Ma 阅读(619) 评论(0) 推荐(0) 编辑
摘要: ZOJ Problem Set - 2987MisspellingTime Limit:1 Second Memory Limit:32768 KBMisspelling is an art form that students seem to excel at. Write a program that removes thenth character from an input string.InputThe first line of input contains a single integerN, (1 <=N<= 1000) which is the number of 阅读全文
posted @ 2011-07-03 00:30 Gavin Lipeng Ma 阅读(412) 评论(0) 推荐(0) 编辑