eBash

It is not the mountain we conquer but ourselves

Project Euler Problem 33

| Comments

Table of Contents

Problem

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 the 9s.

We shall consider fractions like, 30/50 = 3/5, to be trivial examples.

There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.

If the product of these four fractions is given in its lowest common terms, find the value of the denominator.

Solution

很简单,解空间很小,可直接Brute Force.

但我们可以进一步缩小解空间.其可能的四种形式:

  1. \begin{eqnarray*} \frac{10a+b}{10c+b} = \frac{a}{c} \end{eqnarray*}
  2. \begin{eqnarray*} \frac{10a+b}{10b+c} = \frac{a}{c} \end{eqnarray*}
  3. \begin{eqnarray*} \frac{10b+a}{10c+b} = \frac{a}{c} \end{eqnarray*}
  4. \begin{eqnarray*} \frac{10b+a}{10b+c} = \frac{a}{c} \end{eqnarray*}

对于1,4 化简得出a=c,与条件矛盾

对于3,可利用a,b,c <=9 及a<b可得到矛盾

对此只有2才是可能的形式

Answer

100

Source:project-euler

Comments