Merch Shipment


Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python

The Adelaide Competitive Programming Club is shipping out merch orders. Each order starts as a single package with a weight of n grams. The warehouse processes each package using a conveyor:

  • If its current weight x is at most k, it is considered a stable parcel and is set aside for dispatch.
  • Otherwise, if x is divisible by 3, split it into three equal packages of weight x / 3 (which is an integer) each and push them to the back of the conveyor.
  • Otherwise, split it into two packages of weight floor(x / 2) and ceil(x / 2) 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 n and k, find:

  1. The total number of stable parcels dispatched.
  2. The total number of split operations performed.
  3. 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 n (1 \le n \le 10^6) and k (1 \le k < 10^6), 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 (2 \le 4).
  • 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

There are no comments at the moment.