A problem about infeasibly large amounts of seriously overpackaged candy. Problem statement: But today being his birthday, some friends came to visit Andy, and Andy decided to share some candies with them. In order to do that, he must open some of the boxes. Naturally, Andy can not open a box that is still inside an unopened box. If Andy wants to retrieve $X$ candies, what is the least number of boxes he must open? You must help him answer many such queries. Each query is independent. My path to solution Clearly we know how many of the inmost boxes need to be opened  take $X/a_1$ and round up. This suggested two ways forward:
I tried both versions; the second version seemed easier to understand and precalculate for. Then I came up with the idea of effective boxes vs. wrappers. A wrapper is what I called a box that only has one box inside it. If an effective box has $k$ wrappers then you don't need to recalculate for each level of wrapping  just multiply that effective box count by $k+1$. This means we can collapse the box structure into effective boxes each with a multiplier, based on the number of wrappers above it. Then we can track our effective boxes up until we have enough box structure to hold the largest number of candies in a query. The limit on candy query size means that we only need to worry about at most $60$ effective boxes. And bingo, we have a reasonable amount of work per query and we can deliver the answer in the time available. There's more detail but I'll leave that for you to work out. Handy general hint asked 11 Aug '18, 10:18

I didn't see an editorial on this problem so I thought I would write this as a forum for discussion etc.