One morning, Polycarp woke up and realized that 1543 is the most favorite number in his…
- User
One morning, Polycarp woke up and realized that 1543 is the most favorite number in his life. The first thing that Polycarp saw that day as soon as he opened his eyes was a large wall carpet of size n by m cells; n and m are even integers. Each cell contains one of the digits from 0 to 9 Polycarp became curious about how many times the number 1543 would appear in all layers∗ of the carpet when traversed clockwise. The first layer of a carpet of size n×m is defined as a closed strip of length 2⋅(n+m−2) and thickness of 1 element, surrounding its outer part. Each subsequent layer is defined as the first layer of the carpet obtained by removing all previous layers from the original carpet.
- Assistant