Title Description
In a three-bit integer, for example 153 can satisfy 1^3 + 5^3 + 3^3 = 153, so the number is called Armstrong number. To sort all the Armstrong numbers in small order, try to write out a program to find out the number of three-bit Armstrong for the specified sequence number.
Input
The input includes several lines, one ordinal for each line. Enter a sequence number of 0 o'clock to end the input.
Output
Output The Armstrong number of the corresponding ordinal, if the input ordinal is greater than Armstrong number, output 0.
Sample input1460Sample output1534070
1#include <iostream>2#include <vector>3 using namespacestd;4 5 intMain ()6 {7 intres[Ten] = {};8 intf,m,b;9 for(intarms= -;arms< +; arms++)Ten { Onef = arms/ -; Am = (arms% -)/Ten; -b = arms%Ten; - the if((f*f*f+m*m*m+b*b*b) = =arms) -RES[F] =Arms; - } - intInput =-1; + while(input!=0) { -scanf"%d",&input); + if(res[input]!=0) Acout << Res[input] <<Endl; at } -cout <<0<<Endl; -}
Number of Armstrong