
算法
文章平均质量分 68
iteye_12241
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
冒泡法排序
冒泡法就是每一次的遍历找,将最大的元素置于最顶层,然后对剩下重复上述过程!在将最大的元素置于顶层有两种方法(我目前想到的)1.记下下标,然后交换2.遍历的过程就交换下述方法用的第二种[code="java"]public static void MaoPao(int array[]) { // index记录每次最大值的下标 int index; ...原创 2011-03-27 19:33:39 · 91 阅读 · 0 评论 -
Problem 37
问题描述:The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similar...原创 2011-08-17 15:26:00 · 151 阅读 · 0 评论 -
Problem 36
问题描述:The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.(Please note t...原创 2011-08-17 15:23:48 · 108 阅读 · 0 评论 -
Problem 35
问题描述:The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31...原创 2011-08-17 15:22:28 · 134 阅读 · 0 评论 -
Problem 34
问题描述:145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.Find the sum of all numbers which are equal to the sum of the factorial of their digits.Note: as 1! = 1 and 2! = 2 are not su...原创 2011-08-17 15:20:17 · 107 阅读 · 0 评论 -
Problem 33
问题描述:The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling ...原创 2011-08-17 15:18:17 · 127 阅读 · 0 评论 -
Problem 32
问题描述:We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.The product 7254 i...原创 2011-08-17 15:17:17 · 160 阅读 · 0 评论 -
Problem 30
问题描述: Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:1634 = 14 + 64 + 34 + 448208 = 84 + 24 + 04 + 849474 = 94 + 44 + 74 + 44As 1 ...原创 2011-08-17 15:11:39 · 94 阅读 · 0 评论 -
Problem 29
问题描述:Consider all integer combinations of ab for 2 a 5 and 2 b 5:22=4, 23=8, 24=16, 25=3232=9, 33=27, 34=81, 35=24342=16, 43=64, 44=256, 45=102452=25, 53=125, 54=625, 55=3125If they are the...原创 2011-08-17 15:09:10 · 114 阅读 · 0 评论 -
Problem 28
问题描述:Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:21 22 23 24 2520 7 8 9 1019 6 1 2 1118 5 4 3 1217 16 15 14 13It c...原创 2011-08-17 15:06:02 · 161 阅读 · 0 评论 -
Problem 27
问题描述:Euler published the remarkable quadratic formula:n² + n + 41It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 402 + 40 + 41 ...原创 2011-08-17 15:03:26 · 96 阅读 · 0 评论 -
Problem 25
问题描述:The Fibonacci sequence is defined by the recurrence relation:Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.Hence the first 12 terms will be:F1 = 1F2 = 1F3 = 2F4 = 3F5 = 5F6 = 8F7 = 13F8 = 21F...原创 2011-08-17 14:55:08 · 124 阅读 · 0 评论 -
Problem 38
问题描述:Take the number 192 and multiply it by each of 1, 2, and 3:192 * 1 = 192192 * 2 = 384192 * 3 = 576By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 19238...原创 2011-08-17 15:27:17 · 114 阅读 · 0 评论 -
Problem 39
问题描述:If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.{20,48,52}, {24,45,51}, {30,40,50}For which value of p ...原创 2011-08-17 15:28:08 · 121 阅读 · 0 评论 -
Problem 40
算法描述:An irrational decimal fraction is created by concatenating the positive integers:0.123456789101112131415161718192021...It can be seen that the 12th digit of the fractional part is 1.If ...原创 2011-08-18 14:27:19 · 138 阅读 · 0 评论 -
插入法排序
开始学习算法!发现动手写和自己看就是不一样!不管怎么样,一步一步来!从简单的开始!插入法排序,和打扑克牌类似,每次抽一张牌,然后依次比较将其插入到合适位置!在比较的过程中,要不断的将比较过的牌后移,否则就得在找到位置后移动,效率就减少了![code="java"]public static void insertSort(int array[]){ int key ,i;...原创 2011-03-25 16:22:46 · 128 阅读 · 0 评论 -
Problem 52
问题描述:It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, an...原创 2011-09-07 19:37:20 · 133 阅读 · 0 评论 -
Problem 51
问题描述: By replacing the 1st digit of *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.By replacing the 3rd and 4th digits of 56**3 wit...原创 2011-09-06 19:46:26 · 133 阅读 · 0 评论 -
Problem 50
问题描述: The prime 41, can be written as the sum of six consecutive primes:41 = 2 + 3 + 5 + 7 + 11 + 13This is the longest sum of consecutive primes that adds to a prime below one-hundred.The...原创 2011-09-03 14:53:46 · 191 阅读 · 0 评论 -
Problem 49
问题描述: The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbe...原创 2011-08-28 15:34:22 · 155 阅读 · 0 评论 -
Problem 47
问题描述: The first two consecutive numbers to have two distinct prime factors are:14 = 2 715 = 3 5The first three consecutive numbers to have three distinct prime factors are:644 = 2² 7...原创 2011-08-27 16:10:21 · 144 阅读 · 0 评论 -
Problem 46
问题描述:It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.9 = 7 + 21215 = 7 + 22221 = 3 + 23225 = 7 + 23227 = 19 + 22233 ...原创 2011-08-26 18:08:58 · 157 阅读 · 0 评论 -
Problem 45
问题描述: Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, ...Pentagonal Pn=n(3n1)/2 1, 5, 12, 22, 35...原创 2011-08-25 18:24:11 · 110 阅读 · 0 评论 -
Problem43
问题描述:The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property....原创 2011-08-24 16:32:49 · 205 阅读 · 0 评论 -
Problem 42
问题描述:The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are:1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...By converting each letter in a wo...原创 2011-08-23 09:18:57 · 118 阅读 · 0 评论 -
Problem 41
问题描述:We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.What is the largest n-di...原创 2011-08-19 15:08:12 · 132 阅读 · 0 评论 -
Problem 24
问题描述:A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetica...原创 2011-08-17 14:53:26 · 160 阅读 · 0 评论 -
Problem 21
问题描述:Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).If d(a) = b and d(b) = a, where a b, then a and b are an amicable pair and each of a an...原创 2011-08-17 09:57:42 · 105 阅读 · 0 评论 -
Problem 10
问题描述:The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes below two million.[code="java"] public static boolean IsPrime(long number) { int begin = 2; ...原创 2011-06-13 21:50:29 · 96 阅读 · 0 评论 -
Problem 9
问题描述:A Pythagorean triplet is a set of three natural numbers, a b c, for which,a2 + b2 = c2For example, 32 + 42 = 9 + 16 = 25 = 52.There exists exactly one Pythagorean triplet for which ...原创 2011-06-13 21:38:41 · 99 阅读 · 0 评论 -
Problem 8
问题描述:Find the greatest product of five consecutive digits in the 1000-digit number.73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156...原创 2011-06-13 21:15:58 · 73 阅读 · 0 评论 -
Problem 7
问题描述:By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10001st prime number?[code="java"]public static boolean IsPrime(long ...原创 2011-06-13 20:37:24 · 139 阅读 · 0 评论 -
Problem 6
问题描述:The sum of the squares of the first ten natural numbers is,12 + 22 + ... + 102 = 385The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2 = 552 = 3025Hence t...原创 2011-06-13 20:27:49 · 122 阅读 · 0 评论 -
Problem 5
问题描述:2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest positive number that is evenly divisible by all of the numbers...原创 2011-06-13 20:06:41 · 134 阅读 · 0 评论 -
Problem 3
问题描述:The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ?找出一个数字的最大因子。[code="java"]public static boolean IsPrime(long number) {...原创 2011-06-12 20:22:27 · 179 阅读 · 0 评论 -
Problem 4
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.Find the largest palindrome made from the product of two 3-digit...原创 2011-06-12 19:17:14 · 122 阅读 · 0 评论 -
Problem2
问题描述Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By consi...原创 2011-06-12 17:57:17 · 118 阅读 · 0 评论 -
Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.[code="j...原创 2011-06-11 21:26:31 · 113 阅读 · 0 评论 -
堆排序
因为要观察稳定性,就自己定义数据元素[code="java"]package sorted.util;/* * Element用作排序算法的元素,value为其对应的值,index为其最开始时的下标 * index主要用来观察稳定行 */public class Element { private int value ; private int index ...原创 2011-05-25 18:25:32 · 81 阅读 · 0 评论 -
得到自然数因子
[code="java"] public static boolean IsPrime(long number) { int begin = 2; int end = (int) Math.sqrt(number) + 1; for (int i = begin; i < end; i++) { if (number % i == 0) return false...原创 2011-06-15 15:45:45 · 183 阅读 · 0 评论