TopcoderArchiveVisit Topcoder
SRM3 Apr 2006
SRM 296

NewAlbum

Problem statement, definition, constraints, and public examples.

Problem Statement

A popular musical group 'Flattened' has decided to release a new album. It consists of nSongs songs. All songs are of the same length (given in seconds). A CD can store cdCapacity seconds of audio. Each pair of consecutive songs must be separated by a 1 second pause. The group director is superstitious, so the number of songs on a CD must never be divisible by 13. Given these constraints, return the smallest number of CDs required to fit the entire album.

Definition

Class:
NewAlbum
Method:
leastAmountOfCDs
Parameters:
int, int, int
Returns:
int
Method signature:
int leastAmountOfCDs(int nSongs, int length, int cdCapacity)
(be sure your method is public)

Constraints

  • nSongs will be between 1 and 100, inclusive.
  • cdCapacity will be between 1 and 10000, inclusive.
  • length will be between 1 and cdCapacity, inclusive.

Examples

  1. 7
    2
    6
    Returns: 4
    There are at most two songs on each CD.
  2. 20
    1
    100
    Returns: 1
    All the songs will fit on a single CD.
  3. 26
    1
    100
    Returns: 2
    Even though all 26 songs will fit on a single CD, we must use two CDs because 26 is divisible by 13.
  4. 26
    3
    51
    Returns: 3
  5. 67
    271
    1000
    Returns: 23
  6. 27
    1
    27
    Returns: 3
Back to all problems