CF2197A.Friendly Numbers

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Friendly Numbers

For an integer xx, we call another integer yy friendly if the following condition holds:

  • y−d(y)=xy - d(y) = x, where d(y)d(y) is the sum of the digits of yy.

For a given integer xx, determine how many friendly numbers it has.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤5001 \le t \le 500). The description of the test cases follows.

Each test case consists of a single line containing one integer xx (1≤x≤1091 \le x \le 10^{9}).

Output

For each test case, output one integer — the answer to the problem.

Note

The number 11 does not have any friendly numbers.

The number 1818 has 1010 friendly numbers: These are all the numbers from 2020 to 2929. For example, 20−d(20)=20−2=1820 - d(20) = 20 - 2 = 18.

The number 998 244 360998\,244\,360 has 1010 friendly numbers:

  • 998 244 400998\,244\,400
  • 998 244 401998\,244\,401
  • 998 244 402998\,244\,402
  • 998 244 403998\,244\,403
  • 998 244 404998\,244\,404
  • 998 244 405998\,244\,405
  • 998 244 406998\,244\,406
  • 998 244 407998\,244\,407
  • 998 244 408998\,244\,408
  • 998 244 409998\,244\,409

Samples

3
1
18
998244360
0
10
10

在线编程 IDE

建议全屏模式获得最佳体验