Can He Reach The Destination

3.7

7 votes
Very-Easy
Problem

Jainam is a superman but he can only make two types of moves: moves of length 1 meter, and moves of length B meters.

Jainam is going to make exactly K moves, all the moves along same direction. He would like to travel exactly D meters in those K moves. Is this possible?

You are given D, K and B. Print "Possible" (quotes for clarity) if there is a combination of K jumps in same direction of total length equal to exactly D meters. Otherwise, print "Impossible".

Input:

  • First line contains no. of test cases T
  • Input for T test cases follows
  • Each test case contains three space separated integers D, K, B .

Output:

One line for each test case, whether it is "Possible" or "Impossible" for him to move exactly D meters forward in K steps.

Constraints:

1 <= T <= 100

1 <= D <= 10^18

1 <= K <= 1,000,000,000

1 <= B <= 1,000,000,000

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Case 1: Jainam can make two of the jumps of 3 meters and the other four must be of length 1 meter

Case 2: It is not possible to .move exactly 9 meters in 2 steps since he is allowed to move only in one direction.

Editor Image

?