Statistics

Problem Statement for "Ones"

Problem Statement

PROBLEM STATEMENT:
At your disposal are: the numeral one, addition, multiplication, and the
parentheses.  Express a given number with the fewest amount of ones possible.

DEFINITION:
Class Name:  Ones
Method Name: express
Parameters:  int
Return:	     int
Method signature: (make sure your method is public) int express(int n)

INPUTS:
n is an integer between 1 and 10000 inclusive

EXAMPLES
3   returns 3   (1+1+1)
7   returns 6   (1+1+1)*(1+1)+1
46  returns 12  (1+1+1)*(1+1+1)*(1+1+1+1+1)+1
1983 returns 23 (1+1+1)*(((1+1)*(1+1+1)*(1+1+1)*(1+1+1)+1)*(1+1+1)*(1+1+1+1)+1)

FURTHER EXAMPLES
94    returns 15
167   returns 17
661   returns 20
10000 returns 28

Definition

Class:
Ones
Method:
express
Parameters:
int
Returns:
int
Method signature:
int express(int param0)
(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: