#P1940. Reversible Number

Reversible Number

题目背景

本题改编自 Project Euler Problem 145:

Some positive integers n have the property that the sum [ n + reverse(n) ] consists entirely of odd (decimal) digits. For instance, 36 + 63 = 99 and 409 + 904 = 1313. We will call such numbers reversible; so 36, 63, 409, and 904 are reversible. Leading zeroes are not allowed in either n or reverse(n).

There are 120 reversible numbers below one-thousand.

How many reversible numbers are there below one-billion (10^x)?

题目描述

有些正整数 nn 可能满足 n+rev(n)n+\text{rev}(n)rev(n)\text{rev}(n) 是把 nn 倒过来写所得的数)得到的结果的各位都是奇数。

比方说:

  • n=36n=36 时,36+63=9936+63=99
  • n=409n=409 时,409+904=1313409+904=1313

规定满足上述的 nn 称为 Reversible 数。所以 36,63,409,90436,63,409,904 都是 Reversible 数。

当然,以 00 开头的数统统不算 Reversible 数。

那么,小于等于 10x10^x 的 Reversible 数有多少个?

输入格式

一个正整数 xx

输出格式

一行一个整数,表示答案。

4

720

提示

对于 30%30\% 的数据,保证答案不大于 23212^{32}-1

对于 100%100\% 的数据,3x4003 \le x \le 400