TopcoderArchiveVisit Topcoder
TCO8 Dec 2018
TCO19 SRM 743

PlayingWithPlanks

Problem statement, definition, constraints, and public examples.

Problem Statement

You are given a plank of length plankLength. You want to cut the plank into exactly pieces pieces such that the length of each piece is a (positive) integer and all the lengths are distinct.

If it is possible to cut the plank in the described way, return "possible". Otherwise return "impossible".

Definition

Class:
PlayingWithPlanks
Method:
canItBeDone
Parameters:
int, int
Returns:
String
Method signature:
String canItBeDone(int plankLength, int pieces)
(be sure your method is public)

Notes

  • Note that the return value is case-sensitive.

Constraints

  • plankLength will be between 1 and 1,000,000, inclusive.
  • pieces will be between 1 and 1,000, inclusive.

Examples

  1. 9
    3
    Returns: "possible"
    One possibility is to cut the plank into pieces of lengths 1, 3 and 5.
  2. 12
    1
    Returns: "possible"
  3. 9
    4
    Returns: "impossible"
    It can be shown that there is no way to cut a plank of length 9 into 4 pieces of different integer lengths.
  4. 10
    4
    Returns: "possible"
  5. 750932
    901
    Returns: "possible"
  6. 54
    10
    Returns: "impossible"
Back to all problems