Number of Armstrong

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.