#C10730. Sum of Palindromic Numbers
Sum of Palindromic Numbers
Sum of Palindromic Numbers
You are given a sequence of tokens. Some tokens represent integers while others may be non-numeric strings. Your task is to compute the sum of all positive integers in the sequence that are palindromic. A number is considered a palindrome if its decimal representation reads the same forwards and backwards. Formally, an integer n (with n > 0) is a palindrome if it satisfies the following condition in \( \LaTeX \):
\[ \text{str}(n) = \text{reverse}(\text{str}(n)) \]
Note that negative numbers, zero, and non-integer values should be ignored.
The input is provided through standard input (stdin
) and the output should be printed to standard output (stdout
).
inputFormat
The first line contains an integer n which represents the number of tokens in the sequence. The second line contains n tokens separated by spaces. Each token may represent an integer or a non-integer string.
outputFormat
Output a single integer which is the sum of all positive palindromic numbers from the given sequence.
## sample7
121 12321 -121 101 44 202 hello
12789
</p>