TopcoderArchiveVisit Topcoder
SRM7 Jan 2002
SRM 55

Armstrong

Problem statement, definition, constraints, and public examples.

Problem Statement

PROBLEM STATEMENT
If the sum of the cubes of the digits of a number equals the number, then that
number is said to be an Armstrong number.  Write a method that counts the
number of Armstrong numbers in a list.

DEFINITION
Class Name:  Armstrong
Method Name: count
Parameters:  int[]
Return:      int

Method signature (be sure your method is public): int count(int[] n)

TopCoder will ensure the validity of the input:
- n is an int[] that is between 0 and 50 inclusive in size
- each number in the int[] is between 0 and 1000000 inclusive

NOTES
- If the int[] n is empty, then the method should return 0. 

EXAMPLES:
{153, 21} returns 1;
153:   1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153  This is an Armstrong number
 21:   2^3 + 1^3 != 21                       This is not an Armstrong number
There was one Armstrong number in the set so the method returns 1.

Examples:
{0,1}               returns 2
{153,4,232,407,999} returns 2
{5,6,7}             returns 0
{}		    returns 0 

Definition

Class:
Armstrong
Method:
count
Parameters:
int[]
Returns:
int
Method signature:
int count(int[] param0)
(be sure your method is public)

Constraints

    Examples

      No public sample cases were explicitly marked for this problem in the original data.

      Back to all problems