#P5863. Decomposing a Number into the Sum of Two Palindromic Numbers

    ID: 19091 Type: Default 1000ms 256MiB

Decomposing a Number into the Sum of Two Palindromic Numbers

Decomposing a Number into the Sum of Two Palindromic Numbers

A palindromic number is an integer that remains the same when its digits are reversed. For example, the numbers \(142241\) and \(102201\) are palindromic, but \(1023401\) and \(10510\) are not.

Given a positive integer \(n\), count the number of ways to express \(n\) as the sum of two palindromic numbers:

[ a + b = n, ]

where both \(a\) and \(b\) are palindromic numbers. Note that the order matters; that is, \((a, b)\) and \((b, a)\) are considered different decompositions if \(a \neq b\). The numbers \(a\) and \(b\) must both be greater than 0.

inputFormat

The input consists of a single line containing one positive integer \(n\) (\(n\ge1\)).

outputFormat

Output a single integer, the number of pairs \((a, b)\) of palindromic numbers (with \(a, b > 0\)) such that \(a+b=n\).

sample

11
8