java题!求助!

An n-digit number that is the sum of the n-th powers of its digits is called an n-narcissistic number. It is also sometimes known as an Armstrong number, perfect digital invariant (Madachy 1979), or plus perfect number. Hardy (1993) wrote, "There are just four numbers, after unity, which are the sums of the cubes of their digits: 153=1^3+5^3+3^3, 370=3^3+7^3+0^3, 371=3^3+7^3+1^3, and 407=4^3+0^3+7^3. These are odd facts, very suitable for puzzle columns and likely to amuse amateurs, but there is nothing in them which appeals to the mathematician." Narcissistic numbers therefore generalize these "unappealing" numbers to other powers (Madachy 1979, p. 164).

The smallest example of a narcissistic number other than the trivial 1-digit numbers is:
153=1^3+5^3+3^3

For a given positive number "n", which indicates that there are n-digits. You are requested to find and output all these Narcissistic Numbers in order. If no such number exists, output "No".

Input

An Integer n

Output

All the Narcissistic Numbers of n-digit in natural order.

Sample Input

1

Sample Output

1 2 3 4 5 6 7 8 9
就满足153=1^3+5^3+3^3 这样的 这个数字的/各个数位的数字/的数位次方/之和/等于这个数。就是说153=1^3+5^3+3^3这个式子中的三次幂是三位数,如果是两位数就是二次幂。
输入1按顺序显示所有的满足Narcissistic number的一位数
输入2按顺序显示所有的满足Narcissistic numbers的两位数
题目大概是这个意思。。另外输出的时候数字与数字之间有空格 最后一个数后没有空格而是回车

第1个回答  2016-10-09

三位数的可以啊

但是你这个1位数的和2位数的是什么鬼?

1位数的全符合吧,2位数的我用程序测试没一个的,你自己试试

追问

是全符合..我有这么写过,不过给的结果是这样的

追答

什么啊,问题解决没?1位数全符合,2位数没有,3位数就那4个,对不对?还要4位5位的不?

本回答被提问者采纳
第2个回答  2016-10-09
n的取值范围?
第3个回答  2016-10-09
能翻译么?尴尬追问

就满足153=1^3+5^3+3^3 这样的 这个数字的/各个数位的数字/的数位次方/之和/等于这个数。就是说153=1^3+5^3+3^3这个式子中的三次幂是三位数,如果是两位数就是二次幂。
输入1按顺序显示所有的满足Narcissistic number的一位数
输入2按顺序显示所有的满足Narcissistic numbers的两位数

相似回答