Balanced numbers
Time limit1sMemory limit1024 MB
Given N, sum every balanced number up to 10^N, where the first and last ceil(K/2) digits have equal digit sums, and print the total modulo 315.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Math
- Solved
- No attempts yet
Problem
A positive integer of length K is called balanced if the sum of its first digits equals the sum of its last digits. is the smallest integer greater than or equal to x. For example, and .
12321 is balanced because the first digits sum to 1 + 2 + 3 = 6, and the last digits sum to 3 + 2 + 1 = 6. 13722 is also balanced because 1 + 3 + 7 = 7 + 2 + 2.
is the sum of all balanced numbers less than or equal to . , , and . Given N, print .
Input
The first line contains a positive integer N.
Output
On the first line, print modulo 315.