Codeforces Round 1004 (Div. 2) |
---|
Finished |
You are given two numbers $$$x, y$$$. You need to determine if there exists an integer $$$n$$$ such that $$$S(n) = x$$$, $$$S(n + 1) = y$$$.
Here, $$$S(a)$$$ denotes the sum of the digits of the number $$$a$$$ in the decimal numeral system.
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.
The first line of each test case contains two integers $$$x, y$$$ ($$$1 \le x \le 1000, 1 \le y \le 1000$$$).
For each test case, print "NO" if a suitable $$$n$$$ does not exist. Otherwise, output "YES".
You can output each letter in any case (for example, "YES", "Yes", "yes", "yEs", "yEs" will be recognized as a positive answer).
71 277 77997 999999 11000 11 1118 1
Yes No No Yes No No Yes
In the first test case, for example, $$$n = 100$$$ works. $$$S(100) = 1$$$, $$$S(101) = 2$$$.
In the second test case, it can be shown that $$$S(n) \neq S(n+1)$$$ for all $$$n$$$; therefore, the answer is No.
In the fourth test case, $$$n = 10^{111}-1$$$ works, which is a number consisting of $$$111$$$ digits of $$$9$$$.
Name |
---|