TopcoderArchiveVisit Topcoder
SRM12 Nov 2009
SRM 463

RabbitNumbering

Problem statement, definition, constraints, and public examples.

Problem Statement

Taro and Hanako have rabbits, and they want to assign a distinct integer to each rabbit so they can easily identify them.

The rabbits have expressed their preferences to Taro and Hanako. The i-th rabbit wants an integer between 1 and maxNumber[i], inclusive. Taro and Hanako must obey the preferences of all their rabbits.

Return the number of ways they can assign numbers to their rabbits, modulo 1,000,000,007. If it's impossible to assign distinct integers to the rabbits, return 0.

Definition

Class:
RabbitNumbering
Method:
theCount
Parameters:
int[]
Returns:
int
Method signature:
int theCount(int[] maxNumber)
(be sure your method is public)

Constraints

  • maxNumber will contain between 1 and 50 elements, inclusive.
  • Each element of maxNumber will be between 1 and 1,000, inclusive.

Examples

  1. {5}
    Returns: 5
    They can assign any number between 1 and 5, inclusive, to the only rabbit.
  2. {4, 4, 4, 4}
    Returns: 24
    All permutations of {1, 2, 3, 4} are possible.
  3. {5, 8}
    Returns: 35
  4. {2, 1, 2}
    Returns: 0
  5. {25, 489, 76, 98, 704, 98, 768, 39, 697, 8, 56, 74, 36, 95, 87, 2, 968, 4, 920, 54, 873, 90}
    Returns: 676780400
Back to all problems