eBash

It is not the mountain we conquer but ourselves

Project Euler Problem 30

| Comments

Table of Contents

1 Problem

Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: \begin{eqnarray*} 1634 = 1^4 +6^4 + 3^4 + 4^4 \ \end{eqnarray*} \begin{eqnarray*} 8208 = 8^4 + 2^4 + 0^4 + 8^4 \ \end{eqnarray*} \begin{eqnarray*} 9474 = 9^4 + 4^4 + 7^4 + 4^4 \ \end{eqnarray*} As 1 = \(1^4\) is not a sum it is not included.

The sum of these numbers is 1634 + 8208 + 9474 = 19316.

Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.

2 Solution

很直接,关键是找出上界.个位数是不符合题意的。我们检查多少位时其位数上的值的五次方的和不能表示相应的位数.我们可以看到,到7位数时,其最大就只能表示413343,更不用说8位,9位等了.故上界为354294

\begin{eqnarray*} 9^5 + 9^5 = 118098 \ \end{eqnarray*} \begin{eqnarray*} 9^5 + 9^5 + 9^5 = 177147 \ \end{eqnarray*} \begin{eqnarray*} 9^5 + 9^5 + 9^5 + 9^5 = 236196 \ \end{eqnarray*} \begin{eqnarray*} 9^5 + 9^5 + 9^5 + 9^5 + 9^5 = 295245 \ \end{eqnarray*} \begin{eqnarray*} 9^5 + 9^5 + 9^5 + 9^5 + 9^5 + 9^5 = 354294 \ \end{eqnarray*} \begin{eqnarray*} 9^5 + 9^5 + 9^5 + 9^5 + 9^5 + 9^5 + 9^5 = 413343 \ \end{eqnarray*}

3 Answer

443839

Source:C++

Comments