TopcoderArchiveVisit Topcoder
TCO25 Aug 2014
SRM 632 - TCO14 Wildcard Sweep

GoodSubset

Problem statement, definition, constraints, and public examples.

Problem Statement

You have some cards, each containing a positive integer. You are given a int[] d. Each element of d is one of those integers. The integers are not necessarily distinct.

You are also given an int goodValue. You are interested in non-empty subsets of cards with the following property: The product of integers written on those cards is exactly equal to goodValue.

Let X be the number of subsets with the above property. Compute and return the value (X modulo 1,000,000,007).

Definition

Class:
GoodSubset
Method:
numberOfSubsets
Parameters:
int, int[]
Returns:
int
Method signature:
int numberOfSubsets(int goodValue, int[] d)
(be sure your method is public)

Constraints

  • goodValue will be between 1 and 2,000,000,000, inclusive.
  • d will contain between 1 and 100 elements, inclusive.
  • Each element of d will be between 1 and 2,000,000,000, inclusive.

Examples

  1. 10
    {2,3,4,5}
    Returns: 1
    There is only one good subset:{2,5}.
  2. 6
    {2,3,4,5,6}
    Returns: 2
    There are two good subsets: {2,3} and {6}.
  3. 1
    {1,1,1}
    Returns: 7
    All non-empty subsets of this set of cards are good.
  4. 12
    {1,2,3,4,5,6,7,8,9,10,11,12}
    Returns: 6
  5. 5
    {1,2,3,4}
    Returns: 0
Back to all problems