Villain Hoseok
Time limit1sMemory limit512 MB
Count how many K-digit displays (with leading zeros, value 1 to N) can be reached from the current display by flipping 1 to P of the seven-segment LEDs.
- Level
Medium5 of 10
- Topics
- Brute force, Implementation, Math, Simulation
- Solved
- No attempts yet
Problem
The Chirbogi Building has an elevator that serves floors through . The display showing the elevator's floor shows a -digit number. The number may start with . Each digit from to is shown on the display as below. Each digit is drawn by lighting some of the 7 segments.

For example, when , floors and look like this.

Villain Hoseok plans to flip at least and at most of the LEDs on the Chirbogi Building's elevator display. Flipping means turning a lit segment off and an unlit segment on. For example, to change the digit into , 5 LEDs must be flipped. After flipping, he will change the display to show a valid number between and inclusive, confusing people. As a member of the Association of People Who Love Chirbogi, you want to figure out Hoseok's action in advance and teach him a lesson. Given that the elevator is actually stopped at floor , count the number of ways Hoseok can choose which LEDs to flip.
Input
The first line gives separated by spaces.
Output
Count the number of ways Villain Hoseok can correctly flip the elevator LEDs.