Project Euler with Ruby on WSL [Problem 33]

いつのまにか日曜日

月日が経つのは早い

問題

Digit cancelling fractions

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.

私訳

相殺分数((これまた訳が難しい)

49/98 を約分すると 4/8 (=1/2) と等しい。つまり、この場合は分母と分子に共通する数 '9' を消したものと等しくなっている。 ほかに自明な例として 30/50 がある。

分子と分母がともに 2 桁で、1未満の分数には、この種の非自明な例は 4 つしか存在しない。

この 4 つの非自明な分数の積を約分して、その分母を求めよ。

解答方針

基本は力業かなー。 2桁/2桁かつ1未満は与えられているので、分母は 11~99 の 98 種類しかない。 で、cancel が起きるには必ず片方の桁は共通する必要があるから、 分子のパターンとしては 1 未満の条件を外しても 19x2 種類しかない。