Connection Status:
Competition Arena > LongLongTripDiv2
SRM 615 · 2013-12-22 · by snuke · Simple Math
Class Name: LongLongTripDiv2
Return Type: String
Method Name: isAble
Arg Types: (long long, int, int)
Problem Statement

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".

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
0)
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.

1)
10
5
3
Returns: "Impossible"
2)
50
100
2
Returns: "Impossible"
3)
120
10
11
Returns: "Impossible"
4)
10
10
9999
Returns: "Possible"

Submissions are judged against all 89 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class LongLongTripDiv2 with a public method string isAble(long long D, int T, int B) · 89 test cases · 2 s / 256 MB per case

Submitting as anonymous