TopcoderArchiveVisit Topcoder
SRM17 Jul 2007
SRM 358

SameDigits

Problem statement, definition, constraints, and public examples.

Problem Statement

Let's define a function f over positive integers which returns the longest subsequence of the same digits in the number.
So, f(344488) = 3 and f(123) = 1.

Given an int n and int k, return an int stating how many numbers, no longer than n digits has f(x) = k. Return the result modulo 44444444.

Definition

Class:
SameDigits
Method:
howMany
Parameters:
int, int
Returns:
int
Method signature:
int howMany(int n, int k)
(be sure your method is public)

Constraints

  • n and k will be between 1 and 1000, inclusive.

Examples

  1. 2
    2
    Returns: 9
    The numbers are 11, 22, 33, 44, 55, 66, 77, 88 and 99.
  2. 2
    1
    Returns: 90
  3. 3
    2
    Returns: 171
  4. 723
    38
    Returns: 23525252
Back to all problems