Statistics

Problem Statement for "Counter"

Problem Statement

PROBLEM STATEMENT
Given a range of numbers and a separate value X, your program must return a
tally regarding 2 statistics:
0) The quantity of numbers within the range whose digit sum is X
1) The quantity of numbers within the range whose digit product is X

The ranges used are INCLUSIVE.

For a number like 128:
- The digit sum is 1+2+8 = 11
- The digit product is 1*2*8 = 16
Note - leading zeros are never used while computing a digit product

Create a class Counter that contains the method tallyer, which takes an int
low, an int high, an int value, and returns an int[] that describes the 2
tallies mentioned above respectively.

DEFINITION
Class: Counter
Method: tallyer
Parameters: int, int, int
Returns: int[]
Method signature (be sure your method is public):  int[] tallyer(int low, int
high, int value);

TopCoder will ensure the validity of the inputs.  Inputs are valid if all of
the following criteria are met:
- low is less than high (low < high)
- low is between 0 and 99999998, inclusive
- high is between 1 and 99999999, inclusive
- value is between 0 and 99999999, inclusive

NOTES
- Watch out for timeouts
- The returned int[] should have 2 entries corresponding to the 2 statistics
mentioned above respectively
- The range's lower and upper bounds are given by low, and high respectively
and are inclusive

EXAMPLES
1) low = 0, high = 10, value = 3
Digit Sum: 3 is the only viable value so this index will have the value 1.
Digit Product: 3 is the only viable value so this index will have the value 1.
Returns: {1,1}

2) low = 0, high = 100, value = 5
Digit Sum: 5,14,23,32,41,50 all add to 5 so this value is 6.
Digit Product: 5,15,51 all multiply to 5 so this value is 3.
Returns: {6,3}

3) low = 5, high = 100, value = 0
Digit Sum: No values in range can add to 0 so this is 0.
Digit Product: 10,20,30,40,50,60,70,80,90,100 so this value is 10.
Returns: {0,10}

4) low = 0, high = 99999999, value = 999000
Returns: {0,0}

5) low = 1000, high = 1000000, value = 0
Returns: {0,401950}

Definition

Class:
Counter
Method:
tallyer
Parameters:
int, int, int
Returns:
int[]
Method signature:
int[] tallyer(int param0, int param1, int param2)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: