Statistics

Problem Statement for "DVD"

Problem Statement

PROBLEM STATEMENT

You have several sheets with digit labels (each label contains a single digit).
Each sheet contains twenty labels - each digit from 0 to 9, inclusive, is
represented twice on each sheet. You would like to use these labels to number
your collection of DVDs. 

More precisely, you number your DVDs, starting from 1, in increasing order one
after another. You do not put leading zeros (for example, the second DVD will
not be labeled as 02).  You cannot skip numbers - if you have 5 DVDs, they must
be labeled: 1, 2, 3, 4, 5.

Your task is, given the number of sheets you have, to return the maximum number
of DVDs you can label.
 
DEFINITION
Class: DVD
Method: numbering
Parameters: int
Returns: int
Method signature (be sure your method is public):  int numbering(int num);
 
TopCoder will ensure the validity of the inputs. Inputs are valid if all of the
following criteria are met: 
- num is between 1 and 1000000000 inclusive (That is, between 1 and 10^9)

NOTES
*The long data type is a 64-bit signed integer.

Note for C++ coders: The long data type is specific to the gcc compiler.

EXAMPLES
1. num = 1 returns 10, as for numbers 1 through 10 you need two labels with 1s
and one label for every other digit (0, 2-9). You have no labels with 1s left
for the next number - 11. Hence, return 10

2. num = 2 returns 11

3. num = 3 returns 13

4. num = 7 returns 40

5. num = 13 returns 104

6. num = 987654321 returns 1538270446

7. num = 555555555 returns 1111111110

8. num = 1000000000 returns 1552463826

Definition

Class:
DVD
Method:
numbering
Parameters:
int
Returns:
int
Method signature:
int numbering(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: