The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, …
Let us list the factors of [...]
|
||||||
|
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, … Let us list the factors of [...] ?View Code JAVA1 I decided to post some older solutions I have. I had posted these on my forum; however it does not appear on the search engine so I think this will be more convenient. ?View Code JAVA1 Show Problem 61 Finally, I have found a very efficient answer for Problem 72. It runs under 1 seconds. It uses prime sieve of Eratosthenes. Here is the code in Java ?View Code JAVA1 Show Problem 102 Show Problem 62 For this one I used a map. I calculated the cubes for integers till 10000. Then I sorted every cube. Using a hashmap I calculated the frequency of each sort. If the freq is 5, that gives us the combination. Using another hashmap I associated the integer before cube calculation with the combination. [...] Show Problem 112 This one is very easy if you know the trick. Here is the trick. If you sort a number ascendingly and if it is still equals the same number then it is an increasing one. If you sort it descendingly and is still the same number it is a decreasing one. If neither [...] This problem was fun. You have to come up with a way to count the rectangles in a rectangular grid. I used a four nested loop to count the rectangles. First two loops specify the grid size. Then the other two nested loops do the actual work. I assumed that the answer would be in [...] When I first solved this problem I used BigIntegers. It took about 30 minutes to find the answer. The reason for that is I used BigIntegers and a binarysort in a loop. In fact the numbers used do not exceed integer limit so there is no need to use BigIntegers. So I present the more [...] |
||||||
|
Copyright © 2010 Javaist Blog - All Rights Reserved |
||||||