D - At Most 3 (Contestant ver.) Editorial by spheniscine


For each integer \(x\) between \(1\) and \(99\) inclusive, include the weights \(x\), \(100 \cdot x\), and \(10000 \cdot x\).

This allows any integer from \(1\) to \(999999\) to be expressed as the sum of up to three base-\(100\) “digits”, and \(1000000 = 990000 + 10000\). (Or you can just include a \(10^6\) weight, as we have room for 3 more weights)

Note that this answer is independent of input. In fact this is one of the few problems that can be solved using the “Text” language option.

posted:
last update: