Bluebook

Digits and Sums

Write a program that will find all the three-digit natural numbers that are equal to the sum of the cubes of their digits. The range of number will be 100 ≤ M ≤ N ≤ 999. The input will be two numbers: M and N where M is the lesser 3 digit number and N is the greater 3 digit number.

Sample Input

100 200

Sample Output

153

Explanation of output: For example, the number 153 = 1*1*1 + 5*5*5 + 3*3*3, therefore it should be outputted.

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 26, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

There is no explanation about the way to write the solution in case there are more than one found numbers. That was the cause for I got some WA. Each number should be written on a new line.

Can i get a hint as to why my first two cases are wrong?

Test case #1: Wrong Answer [0.110s, 2.6M] (0/10)
Test case #2: Wrong Answer [0.080s, 2.6M] (0/10)

hint plz!

Write a program that will find all the three-digit natural numbers that are equal to the sum of the cubes of their digits.

That's not what your program's doing -- reread the question and then look at your if statement.

If there are no numbers in the range, what are we suppose to output? I think I am having troubles there because I keep getting 10/30 and it shows that

Your Output:
------------------------------------
------------------------------------

for two of the cases....

can someone help?

There is no case where there are no numbers :)

The problem is that you're reading the input wrong - notice that the two numbers are on the same line.

WOW! That was just stupid...:@

it keeps giving me 10/30....

if there are no numbers; what are we supppose to output?

You got two of three cases wrong, and in each of them there are indeed numbers in that range - so your program should be outputting something but it doesn't.