Common Knowledge
Time limit2sMemory limit512 MB
Count pairs of n-digit scores where each player, seeing only half of both boards, can deduce all 2n digits.
- Level
Medium7 of 10
- Topics
- Combinatorics, Bit manipulation, Math
- Solved
- No attempts yet
Problem
Alice and Bob play a game in which they score points. Each of them has an -digit scoreboard that shows a base 10 number padded with leading zeros. Every digit is drawn on a seven-segment display.

The seven segments are the top, upper left, upper right, middle, lower left, lower right and bottom. Each digit lights up these segments:
For some odd reason the two players cannot see the scoreboards entirely. Alice sees only the lower half of her own scoreboard and the upper half of Bob's scoreboard. Bob sees only the upper half of his own scoreboard and the upper half of Alice's scoreboard. The upper half is the top, upper left, upper right and middle segments; the lower half is the middle, lower left, lower right and bottom segments. The middle horizontal segment belongs to both halves, so both players always see it. For example, someone who sees the upper half of an eight can conclude that the digit is not a zero.

Figure I.1: an example situation for
A pair of -digit scores is fully known if both players work out all digits from what they see. The players cannot communicate.
Count the score pairs that are fully known.
Input
The first line contains the number of digits ().
Output
Print the number of score pairs that can be displayed on the two -digit scoreboards and are fully known by both players.