There is an ancient tall building that uses LED light tubes in the elevator to display the floor numbers. However, due to budget constraints for maintenance, the management is trying to reduce the number of floors the elevator can stop at and then discard unnecessary LED light tubes.
Currently, the number of floors the elevator can stop at has been determined, and the task of reducing the LED light tube wiring has been assigned to you. You know that the building has 10
m floors, with floor numbers ranging from
000 to (10
m-1) and displayed as numbers of length
mmm (which may be left-padded with zeros). For each digit of the floor number, there were originally
777 light tubes, as shown in the figure below, that would flexibly turn on and off according to the required displayed number.
Now,
nnn floors have been selected to continue supporting stops, and the elevator will only display these
nnn floor numbers while moving and stopping. Your task is to minimize the number of light tubes that need to remain operational so that the on and off states of these tubes can be used to determine which of the
nnn possible numbers the stopping floor corresponds to. Your time is very precious, so please calculate the minimum number of light tubes that need to remain operational as soon as possible.