Merch Shipment
The Adelaide Competitive Programming Club is shipping out merch orders. Each order starts as a single package with a weight of grams. The warehouse processes each package using a conveyor:
- If its current weight
is at most
, it is considered a stable parcel and is set aside for dispatch.
- Otherwise, if
is divisible by 3, split it into three equal packages of weight
(which is an integer) each and push them to the back of the conveyor.
- Otherwise, split it into two packages of weight
and
and push them to the back of the conveyor.
Repeat until the conveyor is empty (all packages are stable).
After all parcels are dispatched, the warehouse groups them into batches for delivery. A batch is a group of stable parcels that all have the same weight. The warehouse wants to know which batch is the largest, and if there is a tie, report the one with the greatest weight.
Given and
, find:
- The total number of stable parcels dispatched.
- The total number of split operations performed.
- The weight of the largest batch (by count). If two batches tie in count, report the heavier weight.
Input
The first line contains two space-separated integers (
) and
(
), the initial package weight and the stability limit in grams.
Output
Print three space-separated integers: the number of stable parcels, the number of splits, and the weight of the largest batch.
Example
Input 1
18 4
Output 1
9 4 2
- 18 splits into three 6s (1 split).
- Each 6 splits into three 2s (3 splits).
- All nine 2s are stable (
).
- Total stable = 9, total splits = 4.
There is only one batch: nine parcels of weight 2. Largest batch weight = 2.
Input 2
6 5
Output 2
3 1 2
Input 3
1024 3
Output 3
512 511 2
Comments