Codeforces Global Round 28
A
Kevin and Combination Lock
Codeforces
800
原题
←B →
翻译中…

Kevin is trapped in Lakeside Village by Grace. At the exit of the village, there is a combination lock that can only be unlocked if Kevin solves it.

翻译中…

The combination lock starts with an integer $ x $. Kevin can perform one of the following two operations zero or more times:

翻译中…
  1. If $ x \neq 33 $, he can select two consecutive digits $ 3 $ from $ x $ and remove them simultaneously. For example, if $ x = 13\,323 $, he can remove the second and third $ 3 $, changing $ x $ to $ 123 $.
  2. If $ x \geq 33 $, he can change $ x $ to $ x - 33 $. For example, if $ x = 99 $, he can choose this operation to change $ x $ to $ 99 - 33 = 66 $.
翻译中…

When the value of $ x $ on the combination lock becomes $ 0 $, Kevin can unlock the lock and escape from Lakeside Village. Please determine whether it is possible for Kevin to unlock the combination lock and escape.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$).

翻译中…

The only line of each test case contains a positive integer $x$ ($1\leq x\leq 10^9$).

翻译中…

Output

翻译中…

For each test case, output "YES" or "NO" (without quotes) in one line, representing whether Kevin can unlock the combination lock and escape. You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

翻译中…

Note

翻译中…

For the first test case, $165\xrightarrow{-33}132\xrightarrow{-33}99\xrightarrow{-33}66\xrightarrow{-33}33\xrightarrow{-33}0$.

翻译中…

For the second test case, $6369\xrightarrow{-33}6{\color{red}{33}}6\xrightarrow{\text{remove "33"}}66\xrightarrow{-33}33\xrightarrow{-33}0$.

翻译中…

For the third test case, it can be proven that, regardless of the operations performed, $666$ cannot be transformed into $0$.

翻译中…

样例

Input #1
5
165
6369
666
114514
133333332
Output #1
YES
YES
NO
NO
YES
InputCopy OutputCopy
题目信息
题号
2048A
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
模拟
数学
数论

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