TopcoderArchiveVisit Topcoder
SRM22 Dec 2013
SRM 615

LongLongTripDiv2

Problem statement, definition, constraints, and public examples.

Problem Statement

Limit is a flea. He can do two types of jumps: small jumps that have length 1 millimeter, and big jumps that have length B millimeters.

Limit is going to make exactly T jumps, all of them in the same direction. He would like to travel exactly D millimeters in those jumps. Is this possible?

You are given a long D, and ints T and B. Return "Possible" (quotes for clarity) if there is a combination of T jumps forward that has a total length of exactly D millimeters. Otherwise, return "Impossible".

Definition

Class:
LongLongTripDiv2
Method:
isAble
Parameters:
long, int, int
Returns:
String
Method signature:
String isAble(long D, int T, int B)
(be sure your method is public)

Constraints

  • D will be between 1 and 10^18, inclusive.
  • T will be between 1 and 1,000,000,000, inclusive.
  • B will be between 2 and 1,000,000,000, inclusive.

Examples

  1. 10
    6
    3
    Returns: "Possible"
    Limit must make 6 jumps that have a total length of 10 millimeters. This is possible: two of the jumps must be long and the other four must be short.
  2. 10
    5
    3
    Returns: "Impossible"
  3. 50
    100
    2
    Returns: "Impossible"
  4. 120
    10
    11
    Returns: "Impossible"
  5. 10
    10
    9999
    Returns: "Possible"
  6. 1000
    100
    10
    Returns: "Possible"
  7. 1000010000100001
    1100011
    1000000000
    Returns: "Possible"
Back to all problems