Codeforces Round 1079 (Div. 2)
A
Friendly Numbers
Codeforces
800
原题
←B →
翻译中…

For an integer $x$, we call another integer $y$ friendly if the following condition holds:

翻译中…
  • $y - d(y) = x$, where $d(y)$ is the sum of the digits of $y$.
翻译中…

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

翻译中…

Input

翻译中…

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

翻译中…

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

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

The number $1$ does not have any friendly numbers.

翻译中…

The number $18$ has $10$ friendly numbers: These are all the numbers from $20$ to $29$. For example, $20 - d(20) = 20 - 2 = 18$.

翻译中…

The number $998\,244\,360$ has $10$ friendly numbers:

翻译中…
  • $998\,244\,400$
  • $998\,244\,401$
  • $998\,244\,402$
  • $998\,244\,403$
  • $998\,244\,404$
  • $998\,244\,405$
  • $998\,244\,406$
  • $998\,244\,407$
  • $998\,244\,408$
  • $998\,244\,409$
翻译中…

样例

Input #1
3
1
18
998244360
Output #1
0
10
10
InputCopy OutputCopy
题目信息
题号
2197A
时间限制
1 s
内存限制
256 MB
标签
二分
暴力
表达式解析
数学
调度

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。